Table of Contents
This guide covers function feof ()() in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
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
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.