Name

feof

Synopsis

Tests whether the file position is at the end

#include <stdio.h>
intfeof( 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.

Example

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

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.