名前空間
変種
操作

clearerr

提供: cppreference.com
< c‎ | io
 
 
ファイル入出力
型とオブジェクト
関数
ファイルアクセス
直接入出力
書式なし入出力
(C95)(C95)
(C95)
(C95)(C95)
(C95)
(C95)
書式付き入力
 
ヘッダ <stdio.h> で定義
void clearerr(FILE*stream );

指定されたファイルストリームのエラーフラグおよびファイル終端指示子をリセットします。

目次

[編集]引数

stream - エラーフラグをリセットするファイル

[編集]戻り値

(なし)

[編集]

#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)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.19.10.1 The clearerr function (p: 304)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 4.9.10.1 The clearerr function

[編集]関連項目

ファイルの終端を調べます
(関数)[edit]
現在のエラーに対応する文字列を stderr に出力します
(関数)[edit]
ファイルのエラーを調べます
(関数)[edit]
close