test the error indicator for a stream
#include <stdio.h> int ferror( FILE *fp );
The ferror() function tests the error indicator for the stream pointed to by fp.
#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 ); }
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
clearerr(), feof(), perror(), strerror()