C++官网参考链接:https://cplusplus.com/reference/cstdio/clearerr/

函数 
<cstdio>
clearerr
void clearerr ( FILE * stream );
清除错误指示符 
重置stream的错误和文件结束指示符。
当I/O函数由于错误或已到达文件结束而失败时,可以为stream设置这些内部指示符之一。这些指示符的状态可以通过调用这个函数来清除,也可以通过调用rewind,fseek,fsetpos和freopen中的任何一个来清除。

形参
stream 
指向标识流的FILE对象的指针。

返回值
没有返回值。

用例
/* writing errors */
#include <stdio.h>
int main ()
{
  FILE * pFile;
  pFile = fopen("myfile.txt","r");
  if (pFile==NULL) perror ("Error opening file");
  else {
    fputc ('x',pFile);
    if (ferror (pFile)) {
      printf ("Error Writing to myfile.txt\n");
      clearerr (pFile);
    }
    fgetc (pFile);
    if (!ferror (pFile))
      printf ("No errors reading myfile.txt\n"); 
    fclose (pFile);
  }
  return 0;

这个程序打开一个名为myfile.txt的现有文件进行读取,并在尝试写入时导致I/O错误。该错误使用clearerr清除,因此第二次错误检查返回假。
输出:

C++ Reference: Standard C++ Library reference: C Library: cstdio: clearerr相关推荐

  1. Conditional project or library reference in Visual Studio

    Conditional project or library reference in Visual Studio In case you were wondering why you haven't ...

  2. link library 、target library、symbol library、synthetic library对照分析-基础小知识(九)

    文章目录 1.1 概念介绍 1.2 疑问解析 参考文档 DC 应用过程中涉及link library .target library.symbol library.synthetic library, ...

  3. undefined reference to `__stack_chk_guard' .. undefined reference to `__stack_chk_fail'

    1. 编译出错 undefined reference to `__stack_chk_guard' undefined reference to `__stack_chk_fail' 解决方法-1: ...

  4. git fatal: cannot lock ref ‘HEAD‘:unable to resolve reference‘refs/heads/main‘:reference broken

    问题: push的时候,电脑强制关机再启动,vscode中所有文件都变成了绿色,暂存待提交状态 当我再次提交时,就出现错误:git fatal: cannot lock ref 'HEAD':unab ...

  5. undefined reference to 'floor'/undefined reference to

    undefined reference to 'floor'/undefined reference to `& undefined reference to 'pow'/undefined ...

  6. 问题排查--@cannot lock ref 'HEAD': unable to resolve reference 'refs/heads/master': reference broken解决方法

    @cannot lock ref 'HEAD': unable to resolve reference 'refs/heads/master': reference broken解决 作者用的是ID ...

  7. C++ Reference: Standard C++ Library reference: C Library: cmath: cbrt

    C++官网参考链接:https://cplusplus.com/reference/cmath/cbrt/ 函数  <cmath> <ctgmath> cbrt C99 dou ...

  8. C++ Reference: Standard C++ Library reference: C Library: cmath: erf

    C++官网参考链接:https://cplusplus.com/reference/cmath/erf/ 函数  <cmath> <ctgmath> erf C99 doubl ...

  9. C++ Reference: Standard C++ Library reference: C Library: cstdio: printf

    C++官网参考链接:https://cplusplus.com/reference/cstdio/printf/ 函数  <cstdio> printf int printf ( cons ...

最新文章

  1. Keepalived中Master和Backup角色选举策略
  2. Android开发--Spinner控件的使用
  3. BZOJ 2959 长跑 (LCT、并查集)
  4. FB面经Prepare: Email User
  5. windows下安装rabbitMQ教程(实战书写)
  6. 实现输入框小数多 自动进位展示,编辑时实际值不变
  7. linux 通过虚拟ip出路由器,linux模拟路由器实验
  8. UDP协议相关及报文格式
  9. 解决Gerrit的git unpack error问题
  10. python执行js脚本安全吗_手把手教你如何使用Python执行js代码
  11. WebStorm如何设置默认游览器
  12. composer全局 linux_Linux下全局安装composer方法
  13. performSelector:withObject:afterDelay: 的用法
  14. ensure函数_vue按需加载组件webpack require.ensure的方法
  15. 跨时代作品:超级IE缓存提取器
  16. java web程序设计任务教程——源码(全)
  17. Canva可画成为全球增长最快软件公司之一;EDDA科技完成1.5亿美元战略融资 | 美通企业日报...
  18. 无法使用内置管理员账户打开照片,请使用其他账户登录,然后再试一次
  19. excel 表头合并 和拆分的例子
  20. python3爬妹子图_python3爬妹子图

热门文章

  1. 简阳市简阳中学2021年高考成绩查询,四川省简阳中学2021年招生录取分数线
  2. Sketch for Mac(矢量绘图软件)
  3. 进制转换-二进制和十进制的转化
  4. js中iif的真假条件的判断方式
  5. 那些年我在兄弟连学的PHP
  6. 【OpenGL】绘制一个点
  7. android打印 编辑并打印 word
  8. 使用vue2实现打印在线word文件,文件流形式打印在线word,预览打印
  9. jscript经典(待整理)
  10. 自定义json格式-解析为对象