When a stream function fails either because of an error or because the end of the file has been reached, one of these internal indicators may be set. These indicators remain set until either this, rewind, fseek or fsetpos is called.
Parameters
- stream
- Pointer to a FILE object that identifies the stream.
Return Value
NoneExample
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
This program opens an existing file called myfile.txt for reading and causes an I/O error trying to write on it. That error is cleared using clearerr, so a second error checking returns false.
Output:
Error Writing to myfile.txt No errors reading myfile.txt
See also
| feof | Check End-of-File indicator (function) |
| ferror | Check error indicator (function) |
| rewind | Set position indicator to the beginning (function) |
