ferror
ferror is a function in the C standard library that reports whether the error indicator of a FILE stream is set. It is declared in stdio.h and takes a pointer to a FILE object as its argument. The function is used to determine if a recent I/O operation on the stream failed.
The function returns a nonzero value if the stream’s error indicator is set, and zero if it
Importantly, the error indicator is not automatically cleared by successful I/O. To reset the stream’s error
Usage typically involves checking ferror after a loop that reads from or writes to a file, especially
Relation to errno: some implementations may set errno on an I/O error, but the C standard does