Previous Page
Next Page


Tests whether the file position is at the end

#include <stdio.h>
int feof ( FILE *fp  );

The feof( ) macro tests whether the file position indicator of a given file is at the end of the file.

The feof( ) macro's argument is a FILE pointer. One attribute of the file or stream referenced by this pointer is the end-of-file flag, which indicates that the program has attempted to read past the end of the file. The feof( ) macro tests the end-of-file flag and returns a nonzero value if the flag is set. If not, feof( ) returns 0.


See the examples at clearerr( ) and fclose( ) in this chapter.

See Also

rewind( ), fseek( ), clearerr( ), ferror( )

Previous Page
Next Page