#include “stdio.h”

Void perror(__const char *__s);

其中__s是出现错误的地方,函数向标准错误输出设备输出如下:s:错误的详细信息。

Eg.perror(“fopen”);

输出结果:fopen:No such file or directory。

 

#include “string.h”

Char *strerror(int __errnum);

__errnum指错误代码,可以直接使用errno。Strerror函数并不直接输出错误信息,而是返回指向详细错误信息的指针。

注意:errno中的内容应该在出错后立即使用,因为如果出错后不立即使用,可能在调用其他函数时,又产生了错误,导致errno的原有内容被覆盖。

相关文章:

  • 2021-06-04
  • 2021-12-11
  • 2021-11-05
  • 2022-12-23
  • 2022-02-03
  • 2021-10-18
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-02-07
  • 2021-09-16
  • 2022-12-23
相关资源
相似解决方案