十四、错误处理

1、ferror

表头文件  #include<stdio.h>

定义函数  int ferror(FILE *stream);

函数说明  ferror()用来检查参数stream 所指定的文件流是否发生了错误情况,如有错误发生则返回非0 值。

返回值   如果文件流有错误发生则返回非0 值。

2、perror

表头文件  #include<stdio.h> 

定义函数  void perror(const char *s);

函数说明  perror()用来将上一个函数发生错误的原因输出到标准错误(stderr)。参数s 所指的字符串会先打印出,后面再加上错误原因字符串。此错误原因依照全局变量errno 的值来决定要输出的字符串。

返回值   无

3、strerror

表头文件  #include<string.h>

定义函数  char * strerror(int errnum);

函数说明  strerror()用来依参数errnum的错误代码来查询其错误原因的描述字符串,然后将该字符串指针返回。

返回值   返回描述错误原因的字符串指针。

原文地址:https://www.cnblogs.com/Malphite/p/11421478.html