Gets the error status of a file, then clears it.


err = fclearerr(fh)

fh (scalar) – file handle of a file opened with fopen().


err (scalar) – error status equal to 1 if there has been a read or write error on a file, 0 otherwise.


Each file has an error flag that gets set when there is an I/O error on the file. Typically, once this flag is set, you can no longer do I/O on the file, even if the error is a recoverable one. fclearerr() clears the file’s error flag, so you can attempt to continue using it.

If you pass fclearerr() the handle of a file opened with open (i.e., a dataset or matrix file), your program will terminate with a fatal error.

The flag accessed by fclearerr() is not the same as that accessed by fstrerror().