std:: clearerr
From cppreference.net
C++
Input/output library
| 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)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<cstdio>
|
||
|
void
clearerr
(
std::
FILE
*
stream
)
;
|
||
重置指定文件流的错误标志和
EOF
指示器。
目录 |
参数
| stream | - | 用于重置错误标志的文件 |
返回值
(无)
示例
运行此代码
#include <cassert> #include <cstdio> int main() { std::FILE* tmpf = std::tmpfile(); std::fputs("cppreference.net\n", tmpf); std::rewind(tmpf); for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { } assert(std::feof(tmpf)); // 预期循环通过EOF终止 std::puts("End of file reached"); std::clearerr(tmpf); // 清除EOF std::puts(std::feof(tmpf) ? "EOF indicator set" : "EOF indicator cleared"); }
输出:
cppreference.net End of file reached EOF indicator cleared
参考
|
检查文件结尾
(函数) |
|
|
将当前错误对应的字符串显示到
stderr
(函数) |
|
|
检查文件错误
(函数) |
|
|
C 文档
关于
clearerr
|
|