feof
raw OCR
Detects end-of-file on a stream.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
int feof(FILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
feof is a macro that tests the given stream for an end-of-file indicator. Once the indicator is set, read operations on the file return the indicator until rewind is called, or the file is closed.
The end-of-file indicator is reset with each input operation.
feof returns nonzero if an end-of-file indicator was detected on the last
Return value
input operation on the named stream, and 0 if end-of-file has not been reached.
See also
Example
#include <stdio.h>
int main(void)
{
FILE *stream;
stream = fopen("DUMMY.FIL", "r"); /* open a file for reading */
fgetc(stream); /* read a character from the file */
if (feof(stream)) /* check for EOF */
printf("We have reached end-of-file\n");
fclose(stream) ; /* close the file */
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/feof/
· short form /3.1/feof/