[Previous]
[Contents]
[Next]

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 isn't set.
Nonzero
the error indicator is set.

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

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

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


[Previous]
[Contents]
[Next]