In C programming the <stdio.h> feof function tests if the file indicator has reached the end-of-file.The declaration of the function is given below.
|int feof(FILE *stream);|
stream -The pointer to the file whose EOF is to be checked.
int -Returns nonzero if and only if the end-of-file indicator is set for stream.
A code example is given below.
int val , count ;
if (fp != NULL)
while ( true)
val=fgetc(fp); //read character from the file
if( feof(fp) )
fprintf(stderr , “\nEnd of file has reached”);
/*.. process the character **/
printf(“File cannot be opened”);
fclose( fp );
If there is no more character to be read from the file the program prints “End of file has reached”.