Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "windows.h"
- void GetStr(char *d, char **f)
- {
- printf("%s", d);
- for (int i = 0; 1; i++)
- {
- if (i)
- *f = (char*)realloc((*f), i + 1);
- else
- *f = (char*)malloc(i + 1);
- (*f)[i] = getchar();
- if ((*f)[i] == '\n')
- {
- (*f)[i] = '\0';
- break;
- }
- }
- }
- int main()
- {
- char *s = NULL;
- WCHAR arr[4086] = L"2";
- WCHAR tmp = 0;
- GetStr("Plz show me the location of the chipertext file: \n", &s);
- FILE * fname = fopen(s, "r");
- if (fname == NULL)
- {
- printf("Error opening file!\n");
- return -1;
- }
- int m = 0;
- int i = 0;
- while ((tmp = fgetwc(fname)) != WEOF)
- {
- arr[i] = tmp;
- wprintf(L"%c ", arr[i]);
- int k = sizeof(arr[i]);
- wprintf(L"k now: %d\n", k);
- m += k;
- i++;
- }
- int c = wcslen(arr);
- printf("%d", m);
- fclose(fname);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement