Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdio.h>
    int feof( FILE *fp );

Description:
    The feof function tests the end-of-file indicator for the stream pointed
    to by fp.  Because this indicator is set when an input operation
    attempts to read past the end of the file the feof function will detect
    the end of the file only after an attempt is made to read beyond the end
    of the file.  Thus, if a file contains 10 lines, the feof will not
    detect end of file after the tenth line is read; it will detect end of
    file once the program attempts to read more data.

Returns:
    The feof function returns non-zero if the end-of-file indicator is set
    for fp.

See Also:
    clearerr, fopen, freopen, read, ferror, perror

Example:
    #include <stdio.h>

    void main()
      {
        FILE *fp;
        char buffer[100];

        fp = fopen( "file", "r" );
        fgets( buffer, sizeof( buffer ), fp );
        while( ! feof( fp ) ) {
          process_record( buffer );
          fgets( buffer, sizeof( buffer ), fp );
        }
        fclose( fp );
      }

    void process_record( char *buf )
      {
        printf( "%s\n", buf );
      }

Classification:
    ANSI

Systems:
    All

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