| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Types and objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <cstdio> | ||
void clearerr(std::FILE* stream); | ||
Resets the error flags and theEOF indicator for the given file stream.
Contents |
| stream | - | the file to reset the error flags for |
(none)
#include <cassert>#include <cstdio> int main(){std::FILE* tmpf=std::tmpfile();std::fputs("cppreference.com\n", tmpf);std::rewind(tmpf); for(int ch;(ch=std::fgetc(tmpf))!=EOF;std::putchar(ch)){} assert(std::feof(tmpf));// the loop is expected to terminate by EOFstd::puts("End of file reached"); std::clearerr(tmpf);// clear EOF std::puts(std::feof(tmpf)?"EOF indicator set":"EOF indicator cleared");}
Output:
cppreference.comEnd of file reachedEOF indicator cleared
| checks for the end-of-file (function)[edit] | |
| displays a character string corresponding of the current error tostderr (function)[edit] | |
| checks for a file error (function)[edit] | |
C documentation forclearerr | |