clearerr
From cppreference.com
| ヘッダー <stdio.h> で定義 |
||
| void clearerr( FILE *stream ); |
||
指定されたファイルストリームのエラーフラグとEOFインジケータをリセットします。
目次 |
[編集] パラメータ
| stream | - | エラーフラグをリセットするファイル |
[編集] 戻り値
(なし)
[編集] 例
このコードを実行
#include <stdio.h> #include <assert.h> int main(void) { FILE* tmpf = tmpfile(); fputs("cppreference.com\n", tmpf); rewind(tmpf); for (int ch; (ch = fgetc(tmpf)) != EOF; putchar(ch)) { } assert(feof(tmpf)); // the loop is expected to terminate by EOF puts("End of file reached"); clearerr(tmpf); // clear EOF puts(feof(tmpf) ? "EOF indicator set" : "EOF indicator cleared"); }
出力
cppreference.com End of file reached EOF indicator cleared
[編集] 参考文献
- C17標準 (ISO/IEC 9899:2018)
- 7.21.10.1 clearerr関数 (p: 246)
- C11標準 (ISO/IEC 9899:2011)
- 7.21.10.1 clearerr関数 (p: 338)
- C99標準 (ISO/IEC 9899:1999)
- 7.19.10.1 clearerr関数 (p: 304)
- C89/C90標準 (ISO/IEC 9899:1990)
- 4.9.10.1 clearerr関数
[編集] 関連項目
| ファイルの終端をチェックする (関数) | |
| 現在のエラーに対応する文字列をstderrに表示する (関数) | |
| ファイルエラーをチェックする (関数) | |
| C++ドキュメント (clearerr)
| |