C++ Reference: Standard C++ Library reference: C Library: cstdio: clearerr
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相关推荐
- 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 ...
- link library 、target library、symbol library、synthetic library对照分析-基础小知识(九)
文章目录 1.1 概念介绍 1.2 疑问解析 参考文档 DC 应用过程中涉及link library .target library.symbol library.synthetic library, ...
- 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: ...
- git fatal: cannot lock ref ‘HEAD‘:unable to resolve reference‘refs/heads/main‘:reference broken
问题: push的时候,电脑强制关机再启动,vscode中所有文件都变成了绿色,暂存待提交状态 当我再次提交时,就出现错误:git fatal: cannot lock ref 'HEAD':unab ...
- undefined reference to 'floor'/undefined reference to
undefined reference to 'floor'/undefined reference to `& undefined reference to 'pow'/undefined ...
- 问题排查--@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 ...
- C++ Reference: Standard C++ Library reference: C Library: cmath: cbrt
C++官网参考链接:https://cplusplus.com/reference/cmath/cbrt/ 函数 <cmath> <ctgmath> cbrt C99 dou ...
- C++ Reference: Standard C++ Library reference: C Library: cmath: erf
C++官网参考链接:https://cplusplus.com/reference/cmath/erf/ 函数 <cmath> <ctgmath> erf C99 doubl ...
- C++ Reference: Standard C++ Library reference: C Library: cstdio: printf
C++官网参考链接:https://cplusplus.com/reference/cstdio/printf/ 函数 <cstdio> printf int printf ( cons ...
最新文章
- Keepalived中Master和Backup角色选举策略
- Android开发--Spinner控件的使用
- BZOJ 2959 长跑 (LCT、并查集)
- FB面经Prepare: Email User
- windows下安装rabbitMQ教程(实战书写)
- 实现输入框小数多 自动进位展示,编辑时实际值不变
- linux 通过虚拟ip出路由器,linux模拟路由器实验
- UDP协议相关及报文格式
- 解决Gerrit的git unpack error问题
- python执行js脚本安全吗_手把手教你如何使用Python执行js代码
- WebStorm如何设置默认游览器
- composer全局 linux_Linux下全局安装composer方法
- performSelector:withObject:afterDelay: 的用法
- ensure函数_vue按需加载组件webpack require.ensure的方法
- 跨时代作品:超级IE缓存提取器
- java web程序设计任务教程——源码(全)
- Canva可画成为全球增长最快软件公司之一;EDDA科技完成1.5亿美元战略融资 | 美通企业日报...
- 无法使用内置管理员账户打开照片,请使用其他账户登录,然后再试一次
- excel 表头合并 和拆分的例子
- python3爬妹子图_python3爬妹子图