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.

See also:

feof(), ferror(), perror()

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

Systems:

All (except DOS/PM)