C Programming/stdio.h/feof

feof is a C standard library function declared in the header stdio.h. Its primary purpose is to distinguish between cases where a stream operation has reached the end of a file and cases where the  ("end of file") error code has been returned as a generic error indicator, without the end of the file's actually having been reached.

Function prototype
The function is declared as follows:

It takes one argument: a pointer to the  structure of the stream to check.

Return value
The return value of the function is an integer. A nonzero value signifies that the end of the file has been reached; a value of zero signifies that it has not.

Pitfalls
A common misuse of the function is trying to use feof "preemptively". However, this doesn't work correctly, as feof is only set for a descriptor after a reading function has failed.