Next: fflush, Previous: feof, Up: Stdio

### 4.6 `ferror`—test whether read/write error has occurred

Synopsis

         #include <stdio.h>
         int ferror(FILE *fp);

Description
The `stdio` functions maintain an error indicator with each file pointer fp, to record whether any read or write errors have occurred on the associated file or stream. Use `ferror` to query this indicator.

See `clearerr` to reset the error indicator.

Returns
`ferror` returns `0` if no errors have occurred; it returns a nonzero value otherwise.

Portability
ANSI C requires `ferror`.

No supporting OS subroutines are required.