/*********************************************
* @brief 获取错误码的可读文本说明
* @param errornum 错误码
* @return 错误码的可读文本说明
********************************************/
char* strerror(int errornum);
!subtitle:说明
将错误码 errornum 转换为用户可读的文本说明。
!subtitle:参数
errornum - 错误码
!subtitle:返回值
文本形式错误说明的字符串
#include <stdio.h>
#include <errno.h> // errno
#include <string.h> // strerror
int main(void)
{
printf("%d : %s\n", errno, strerror(errno));
printf("%d : %s\n", EDOM, strerror(EDOM));
printf("%d : %s\n", EILSEQ, strerror(EILSEQ));
printf("%d : %s\n", ERANGE, strerror(ERANGE));
return 0;
}
运行结果:
0 : Success
33 : Numerical argument out of domain
84 : Invalid or incomplete multibyte or wide character
34 : Numerical result out of range
C11 standard (ISO/IEC 9899:2011):
7.24.6.2 The strerror function (p: 371)
C99 standard (ISO/IEC 9899:1999):
7.21.6.2 The strerror function (p: 334)
C89/C90 standard (ISO/IEC 9899:1990):
4.11.6.2 The strerror function