Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FILE *f = fopen("a.txt", "r");
- fseek(f, 0, 2);
- int size = ftell(f);
- fseek(f, 0, 0);
- printf("%d\n", size);
- char *res = malloc((size+1)*sizeof(char));
- fread(res, sizeof(char), size, f);
- res[size-2] = '\0';
- printf("%s", res);
- char buff[100];
- fseek(f, 0, 0);
- while(!feof(f))
- {
- if (fgets(buff, 100, f) > 0)
- printf("%s", buff);
- }
- fclose(f);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement