feof -- Test End-of-File Indicator

Format

#include <stdio.h>
int feof(FILE *stream);

Language Level: ANSI, POSIX, XPG4
feof indicates whether the end-of-file flag is set for the given stream. The end-of-file flag is set by several functions to indicate the end of the file. The end-of-file flag is cleared by calling rewind, fsetpos, fseek, or clearerr for this stream.

Return Value
feof returns a nonzero value if and only if the EOF flag is set; otherwise, it returns 0.

Example
This example scans the input stream until it reads an end-of-file character.

#include <stdio.h>
#if (1 == __TOS_OS2__)
  #define FILENAME "myfile.dat"      /* OS/2 file name */
#else
  #define FILENAME "myfile.dat"   /* Windows file name */
#endif
int main(void)
{
   char inp char;
   FILE *stream;
   stream = fopen("FILENAME", "r");
   /* scan an input stream until an end-of-file character is read. */
   while  (0 == feof(stream)) {
        fscanf(stream, "%c", &inp_char);
        printf("<x%x>", inp_char);
}
   fclose(stream);
   return 0;
   /*********************************************************
      If FILENAME contains : abc defgh
      The output should be:
      <x61> <x62> <x63> <x64> <x65> <x66> <x67> <x68>
   *********************************************************/
}


clearerr -- Reset Error Indicators
ferror -- Test for Read/Write Errors
fseek -- Reposition File Position
fsetpos -- Set File Position
perror -- Print Error Message
rewind -- Adjust Current File Position
<stdio.h>