> feof<STDIO.H> ~ Online tutorial

feof



feof                     <STDIO.H>

 Macro that tests if end-of-file has been reached on a stream.


 Declaration:

 int feof(FILE *stream);

 Remarks:


feof is a macro that tests the given stream for an end-of-file indicator.

Once the indicator is set, read operations on the file return the indicator
until rewind is called, or the file is closed.

The end-of-file indicator is reset with each input operation.

 Return Value:


  Returns non-zero if an end-of-file
    indicator was detected on the last input
    operation on the named stream.
 Returns 0 if end-of-file has not been
    reached.




 Example:

 #include <stdio.h>

 int main(void)
 {
    FILE *stream;

    /* open a file for reading */
    stream = fopen("DUMMY.FIL", "r");

    /* read a character from the file */
    fgetc(stream);

    /* check for EOF */
    if (feof(stream))
       printf("We have reached end-of-file\n");

    /* close the file */
    fclose(stream);
    return 0;
 }

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: