feof() Detect Stream End-of-File (Macro)
#include <stdio.h>
int feof(stream);
FILE *stream; Pointer to file structure
feof() is a macro that tests 'stream' for the end-of-file. Once the
EOF indicator has been set, read operations return an end-of-file
indicator until rewind() is called or 'stream' is closed.
Returns: A non-zero value when the end-of-file has been reached.
Zero is returned if the current position is not
end-of-file. There is no error return.
-------------------------------- Example ---------------------------------
This example opens a file, prints its contents until end-of-file is
reached, then closes the file.
#include <stdio.h>
FILE *stream;
int c;
main()
{
if ((stream = fopen("stat.dat","r+")) != NULL) {
while(!feof(stream)) {
c = getc(stream);
printf("%c",c);
}
fclose(stream);
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster