eof()                    Test for End of File
 
 
 #include <io.h>
 
 int        eof(handle);
 int        handle;                      Handle referring to open file
 
    eof() checks whether end-of-file has been reached for the file
    associated with 'handle'.
 
    Returns:     1  End of file reached
                 0  Current position is not end of file
                -1  An error occurred.
 
                On error, 'errno' is set to:
 
                       EBADF:        a bad file handle.
 
  -------------------------------- Example ---------------------------------
 
    The following statements open a file for reading then count the number
    of bytes read until end of file is reached.
 
         #include <io.h>
         #include <fnctl.h>
 
         int fhndl, count, totalbytes;
         char buff[1000];
 
         main()
         {
               fhndl = open("data",O_RONLY);
               totalbytes = 0;
               while (!eof(fhndl)) {
                     count = read(fhndl, buff, 10);
                     totalbytes += count;
                }
           }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster