Defined in header <stdio.h> | ||
---|---|---|
void clearerr( FILE *stream ); |
Resets the error flags and the EOF
indicator for the given file stream.
stream | - | the file to reset the error flags for |
(none).
#include <stdio.h> #include <stdlib.h> #include <assert.h> int main(void) { FILE* tmpf = tmpfile(); fputs("abcde\n", tmpf); rewind(tmpf); int ch; while ((ch=fgetc(tmpf)) != EOF) printf("%c", ch); assert(feof(tmpf)); // the loop is expected to terminate by eof puts("End of file reached"); clearerr(tmpf); // clear eof if (feof(tmpf)) puts("EOF indicator set"); else puts("EOF indicator cleared\n"); }
Output:
abcde End of file reached EOF indicator cleared
checks for the end-of-file (function) |
|
displays a character string corresponding of the current error to stderr (function) |
|
checks for a file error (function) |
|
C++ documentation for clearerr |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/c/io/clearerr