Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>feof() detect stream end-of-file (macro)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 feof()                  Detect Stream End-of-File (Macro)

 #include   <stdio.h>

 int        feof(stream);
 FILE       *stream;                     Pointer to file structure

    feof() is a macro that tests 'stream' for the end-of-file. If the EOF
    indicator has been set, an end-of-file indicator is returned for all
    read operations either until rewind() or clearerr() is called or
    'stream' is closed.

    Returns:    Non-zero when the end-of-file has been reached; zero if
                the current position is not end-of-file.  There is no
                error return.

   -------------------------------- Example ---------------------------------

    This example opens a file, prints its contents until end-of-file is
    reached, then closes the file.

           #include <stdio.h>

           FILE *stream;
           int c;

           main()
           {
               if ((stream = fopen("stat.dat","r+")) != NULL) {
                    while(!feof(stream)) {
                        c = getc(stream);
                        printf("%c",c);
                    }
                    fclose(stream);
                }
           }


See Also: eof() clearerr() ferror() perror()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson