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 documentation
for
clearerr
|
|