Function feof () in C
The int feof function (FILE * stream) in the standard Library C checks the end-of-file indicator for the given Stream.
Declare the feof () function in C
Below is the declaration for the feof () function in C:
int feof ( FILE * stream )
Parameters
stream - This is the pointer to a FILE object that identifies the Stream.
Returns the value
This function returns a non-zero value when the End-Of-File Indicator that binds to the Stream is set, otherwise the function returns 0.
For example
The following C program illustrates the usage of the feof () function in C:
#include int main () { FILE * fp ; int c ; fp = fopen ( "baitapc.txt" , "r" ); if ( fp == NULL ) { perror ( "Da xay ra loi trong khi mo baitapc.txt" ); return (- 1 ); } while ( 1 ) { c = fgetc ( fp ); if ( feof ( fp ) ) { break ; } printf ( "%c" , c ); } fclose ( fp ); return ( 0 ); }
Suppose we have a baitcap.txt with the following content. This file will be used as an input for our C program:
Learn more about QTM and more
Compile and run the above C program to see the results:
According to Tutorialspoint
Previous article: Function clearerr () in C
Next lesson: ferror () function in C
You should read it
Maybe you are interested
Difference between function and formula in Excel
8 little-known Excel functions that can save you a lot of work
How to use the NORMDIST function in Excel - Function that returns the distribution in Excel
Date functions in Excel, DAY, WEEKDAY, MONTH
How to use the SUMIF function in Excel to calculate the sum based on conditions
How to use the Round function in Excel to round numbers and process data