[Previous]
[Contents]
[Next]

clearerr()

clear the end-of-file and error indicators for a stream

Synopsis:

#include <stdio.h>
void clearerr( FILE *fp );

Description:

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.

Examples:

#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    */
      }
    }
  }

Classification:

ANSI

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

feof(), ferror(), perror(), strerror()


[Previous]
[Contents]
[Next]