feof() - I/O Function
How is feof() used in C++?
How to check file position indicator for EOF?
is an I/O function that checks the file position indicator for the EOF of the associated stream. This check end of file indicator is generally set by a previous operation on the stream that reached the End-of-File. This function returns a non zero value if the EOF is reached, otherwise "0" is returned.
int feof ( FILE * stream );
long count = 0;
FILE * stri = fopen ("getceg.txt", "r");
if( ferror(stri) )
perror( "Error in File" );
while (!feof (stri))
printf ("Total bytes read in the file: %d\n", count-1);
Total bytes read in the file: 11
In the above example the "feof()" is used to find the total number of bytes read in a text file. The content of the text file is "ABCA1@@ABNM".