Syntax
#include <stdio.h> void clearerr (FILE *stream);Description
There is no return value.
This example reads a data stream and then checks that a read error has not occurred.
#include <stdio.h> #include <stdlib.h> FILE *stream; int c; int main(void) { if (NULL != (stream = fopen("file.dat", "r"))) { if (EOF == (c = getc(stream))) { if (feof(stream)) { perror("Read error"); clearerr(stream); } } } return 0; /**************************************************************************** If file.dat is an empty file, the output should be: Read error: Attempted to read past end-of-file. ****************************************************************************/ }Related Information