Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)


int feof(FILE *stream);

checks that are applied to a stream or data or the end-of-file indicator is set.
Used to determine if the end of the file (stream) specified, has been reached. When a file is being read sequentially one line, or one piece of data at a time (by means of a loop, say), this is the function you check every iteration, to see if the end of the file has come.
Returns non-zero if end-of-file indicator is set for stream stream.

C Sourcecode Example

 * feof example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#define MAX 1000
int main( void )
  char buffer[MAX];
  FILE *filestream;
  filestream = fopen("test.txt","r");
  while (feof(filestream) == 0)
    fgets(buffer, MAX, filestream);
    if (buffer[0] == '#') {
        else {
  return 0;

content of test.txt

Line 1
#Line 2
Line 3
#Line 4 
Line 5

feof output

  user@host:~$ ./feof 
  Line 1
  Line 3
  Line 5

See also

c/stdio.h/feof.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems Impressum