Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      clearerr

      From cppreference.com
      <c‎ |io
       
       
      File input/output
      Types and objects
      Functions
      File access
      Unformatted input/output
      (C95)(C95)
      (C95)
      (C95)(C95)
      (C95)
      (C95)

      Formatted input
       
      Defined in header<stdio.h>
      void clearerr(FILE*stream);

      Resets the error flags and theEOF indicator for the given file stream.

      Contents

      [edit]Parameters

      stream - the file to reset the error flags for

      [edit]Return value

      (none)

      [edit]Example

      Run this code
      #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 EOFputs("End of file reached");     clearerr(tmpf);// clear EOF puts(feof(tmpf)?"EOF indicator set":"EOF indicator cleared");}

      Output:

      cppreference.comEnd of file reachedEOF indicator cleared

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.21.10.1 The clearerr function (p: 246)
      • 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]See also

      checks for the end-of-file
      (function)[edit]
      displays a character string corresponding of the current error tostderr
      (function)[edit]
      checks for a file error
      (function)[edit]
      C++ documentation forclearerr
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/io/clearerr&oldid=142553"

      [8]ページ先頭

      ©2009-2025 Movatter.jp