clearerr
提供: cppreference.com
ヘッダ <stdio.h> で定義 | ||
void clearerr(FILE*stream ); | ||
指定されたファイルストリームのエラーフラグおよびファイル終端指示子をリセットします。
目次 |
[編集]引数
stream | - | エラーフラグをリセットするファイル |
[編集]戻り値
(なし)
[編集]例
Run this code
#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 eofputs("End of file reached"); clearerr(tmpf);// clear eof if(feof(tmpf))puts("EOF indicator set");elseputs("EOF indicator cleared\n");}
出力:
abcde End of file reached EOF indicator cleared
[編集]参考文献
- C11 standard (ISO/IEC 9899:2011):
- 7.21.10.1 The clearerr function (p: 338)