C Now

FILE Stream feof Function

Site Logo

Usage:

The feof function is used to test whether the file pointer is at the end of the file.

Prototype:

int feof (FILE * Stream);

Argument:

Stream
Pointer to an open FILE structure.

Header Files:

stdio.h
(feof)
errno.h
(errno values)

Returns:

 0
File pointer is not at end of file.
 1
File pointer is at end of file. (Set after end of file has been passed.)

Side Effect:

errno
Iff the read fails, the global variable errno is set to error code
EBADF
Handle not open

Example:

#include <stdio.h> 
 .  .  .
  FILE *    Account_Master;
  char      Buffer [100];
  int       Maximum;
  int       Actual;
    .  .  .
  Maximum = 100;
    .  .  .
  Account_Master = fopen ("accounts.dat", "r");
    .  .  .
  Actual = fread (Buffer, 1, Maximum, Account_Master);
  while (!feof (Account_Master)) {
    .  .  .
    Actual = fread (Buffer, 1, Maximum, Account_Master);
}

feof  feof  MSDN
feof,fgets, fread  feof,fgets, fread
C Now Home  C Now Home
Include Files Index  Include Files Index
Header stdio.h Index  Header stdio.h Index
E-Mail
Valid HTML 4.01 Transitional Valid CSS! Site Logo

copyright 2001-2006, j.h.young, revised 2/13/06

feof / feof,fgets, fread /