头文件:#include<stdio.h>
函数:perror、strerror,全局变量:errno。
使用方法:

FILE *fp;
if((fp = fopen("test.txt", "r")) == NULL)
{
perror("test.txt open error");
printf("%s\n",strerror(errno));
printf("%d\n",errno);
exit();
}

输出:

output:

test.txt open error: No such file or directory
No such file or directory

errno是一个int型的全局变量,它(编码成错误编号)返回函数的错误信息(C/C++的库函数大都是有返回值的,以便调用者知道该函数的执行结果),例如上例的错误信息:2

最新文章

  1. git操作的常用命令
  2. 11个提问频率最高的PHP面试题
  3. 妙用Javascript中apply、call、bind
  4. Delphi ActiveX Form的使用实例
  5. memcache 开发版
  6. Delegate 委托复习(-) 委托的基本概念
  7. Nginx配置同一个域名http与https两种方式都可访问
  8. [iOS]C语言技术视频-02-程序分支结构(if...else)
  9. [2017.02.21] 《Haskell趣学指南 —— Learning You a Haskell for Great Good!》
  10. git生成ssh key及github ssh key对接
  11. path和classpath的区别
  12. asp.net 按钮执行前后台方法——前台弹出提示信息,确认后继续执行后台方法,取消则不执行后台方法
  13. Java中单例实现
  14. js 中prototype运用(数组)
  15. matlab练习程序(点云下采样)
  16. 浅析原生js模仿addclass和removeclass
  17. iOS耳机监听
  18. 基于Boost库的HTTP Post函数
  19. Skype for Business Server-呼叫质量仪表板(一)安装与配置
  20. java后台接收json数据,报错com.alibaba.fastjson.JSONObject cannot be cast to xxx

热门文章

  1. iis 0x80070032 Cannot read configuration file because it exceeds the maximum file size
  2. Vue中token的实现
  3. 02 安装net-tools工具
  4. 题解 SP1841 【PPATH - Prime Path】
  5. xilinx fpga 生成3*3窗口
  6. java实现单链表的增删改以及排序
  7. SQL查询基本用法
  8. 面试题三十:包含min函数的栈
  9. 搞事情?Spring Boot今天一口气发布三个版本
  10. 启动扫描闪退,因为忘了在manifest里申请手机镜头使用许可了。