#include <stdio.h>
int main()
{
FILE *f;
f = fopen ("data.txt","r");
int c;
long sz;
fseek (f,0,SEEK_END);
sz = ftell (f);
//rewind (f);
fseek (f,0,SEEK_SET);
printf ("size of file = %d\n",sz);
for (unsignedint i = 0; i<sz ; ++i)
{
c = fgetc (f);
printf ("pos %d = %d\n",i,c);
}
fclose (f);
return 0;
}
I get one EOF (denoted by my compiler as a -1) per every new line in data.txt. IE if there are 4 separate lines then I will have 4 EOFs printed out. Does anyone know why?