Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "windows.h"
  5.  
  6. void GetStr(char *d, char **f)
  7. {
  8. printf("%s", d);
  9.  
  10. for (int i = 0; 1; i++)
  11. {
  12. if (i)
  13. *f = (char*)realloc((*f), i + 1);
  14. else
  15. *f = (char*)malloc(i + 1);
  16. (*f)[i] = getchar();
  17. if ((*f)[i] == '\n')
  18. {
  19. (*f)[i] = '\0';
  20. break;
  21. }
  22. }
  23. }
  24.  
  25. int main()
  26. {
  27. char *s = NULL;
  28. WCHAR arr[4086] = L"2";
  29. WCHAR tmp = 0;
  30. GetStr("Plz show me the location of the chipertext file: \n", &s);
  31. FILE * fname = fopen(s, "r");
  32. if (fname == NULL)
  33. {
  34. printf("Error opening file!\n");
  35. return -1;
  36. }
  37. int m = 0;
  38. int i = 0;
  39. while ((tmp = fgetwc(fname)) != WEOF)
  40. {
  41. arr[i] = tmp;
  42. wprintf(L"%c ", arr[i]);
  43. int k = sizeof(arr[i]);
  44. wprintf(L"k now: %d\n", k);
  45. m += k;
  46. i++;
  47. }
  48. int c = wcslen(arr);
  49. printf("%d", m);
  50.  
  51. fclose(fname);
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement