Hi.
I have one little program code in C:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
FILE *fp;
fp = fopen("TextFile", "r");
if (!fp) {
printf("Error opening file\n");
return 0;
};
char *Line = malloc (200 * sizeof(char));
fseek(fp, 0, SEEK_END);
printf("File size: %li\n\n", ftell(fp));
rewind(fp);
while(!feof(fp)){
fgets(Line,200,fp);
printf("%s", Line);
printf("Reading position: %li\n\n", ftell(fp));
};
return 0;
}
But it prints the last line of text from the file twice and I don't understand why. Isn't the file reading position in the end of file yet or what?