feof() is a state (in response to past events), not a prediction (of future events).
Compare your code with
Code:
while(!feof(file))
{
if ( fgets(buffer,sizeof(buffer),fp) != NULL )
{
printf("%s\n",buffer);
}
}
Or perhaps
Code:
while ( fgets(buffer,sizeof(buffer),fp) != NULL )
{
printf("%s\n",buffer);
}
// here, you use feof() or ferror() to find out the cause of the problem
You should initially check the success/fail of a file reading function. If the read fails, then you use feof() to discover more.
Yes, BUFSIZ is a macro defined in stdio.h