clearerr
來自 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++ 文件 for clearerr
|