clearerr
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    | 在标头  <stdio.h>定义 | ||
| void clearerr( FILE *stream ); | ||
重置给定文件流的错误标志和 EOF 指示器。
参数
| 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)); // 此循环期待以 eof 终止 puts("End of file reached"); clearerr(tmpf); // 清除 eof if (feof(tmpf)) puts("EOF indicator set"); else puts("EOF indicator cleared\n"); }
输出:
abcde End of file reached EOF indicator cleared