clearerr -- Clear Error Flag

SYNOPSIS

 #include <stdio.h>

 void clearerr(FILE *f);
 

DESCRIPTION

clearerr clears the error flag and the end-of-file flag for the FILE object addressed by f.

RETURN VALUE

clearerr has no return value.

IMPLEMENTATION

After the error flag is set for a file, all further I/O to the file fails until the flag is cleared. The standards do not address this subject, and different implementations treat this situation differently. For maximum portability, the error flag should be cleared immediately upon detection of an error if continued use of the file is intended.

In some cases of a severe error, it is impossible to continue to use the file. This situation cannot be detected by clearerr. The nonstandard function clrerr enables you to test for this situation.

EXAMPLE

  #include <lcio.h>

  int fixerr(FILE *f){            /* Clear the error flag for a file. */
     clearerr(f);
     if (ferror(f)){              /* if error flag still set          */
        printf("Error on %s is permanent. Program aborted.n", fnm(f));
        abort();
     }
     return 0;                    /* Show error flag cleared.         */
  }

 

RELATED FUNCTIONS

clrerr, ferror

SEE ALSO


Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.