std::clearerr
來自 cppreference.com
定義於標頭檔案 <cstdio> |
||
void clearerr( std::FILE* stream ); |
||
重置給定檔案流的錯誤標誌和 EOF
指示器。
目錄 |
[編輯] 引數
stream | - | 要重置錯誤標誌的檔案 |
[編輯] 返回值
(無)
[編輯] 示例
執行此程式碼
#include <cassert> #include <cstdio> int main() { std::FILE* tmpf = std::tmpfile(); std::fputs("cppreference.com\n", tmpf); std::rewind(tmpf); for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { } assert(std::feof(tmpf)); // the loop is expected to terminate by EOF std::puts("End of file reached"); std::clearerr(tmpf); // clear EOF std::puts(std::feof(tmpf) ? "EOF indicator set" : "EOF indicator cleared"); }
輸出
cppreference.com End of file reached EOF indicator cleared
[編輯] 參閱
檢查檔案結束 (函式) | |
將當前錯誤的字串顯示到 stderr (函式) | |
檢查檔案錯誤 (函式) | |
C 文件 對應 clearerr
|