ferror

test the error indicator for a stream

Synopsis:

#include <stdio.h>
int ferror( FILE *fp );

Description:

The ferror() function tests the error indicator for the stream pointed to by fp.

Returns:

0
the error indicator is not set.
non-zero
the error indicator is set.

See also:

clearerr(), feof(), perror(), strerror()

Examples:

#include <stdio.h>

void main()
  {
    FILE *fp;
    int c;

    fp = fopen( "file", "r" );
    if( fp != NULL ) {
      c = fgetc( fp );
      if( ferror( fp ) ) {
        printf( "Error reading file\n" );
      }
    }
    fclose( fp );
  }

Classification:

ANSI

Systems:

All (except DOS/PM)