#include <stdio.h> void clearerr(FILE *f);
clearerr
clears the error flag and the end-of-file flag for the
FILE
object addressed by f
.
clearerr
has no return value.
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.
#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. */ }
clrerr
, ferror
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.