clear the end-of-file and error indicators for a stream
#include <stdio.h> void clearerr( FILE *fp );
The clearerr() function clears the end-of-file and error indicators for the stream pointed to by fp. These indicators are cleared only when the file is opened, or by an explicit call to the clearerr() or rewind() functions.
#include <stdio.h> void main() { FILE *fp; int c; c = 'J'; fp = fopen( "file", "w" ); if( fp != NULL ) { fputc( c, fp ); if( ferror( fp ) ) { /* if error */ clearerr( fp ); /* clear the error */ fputc( c, fp ); /* and retry it */ } } }
ANSI
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
feof(), ferror(), perror(), strerror()