C string strerror() 函数

定义和用法

strerror() 函数返回一个描述错误代码含义的字符串。

strerror() 函数定义在 <string.h> 头文件中。

实例

输出各种错误信息:

printf("%s\n", strerror(0));
printf("%s\n", strerror(1));
printf("%s\n", strerror(2));
printf("%s\n", strerror(3));

亲自试一试

语法

strerror(int errcode);

参数

参数 描述
errcode 必需。一个错误代码。

技术细节

返回: 返回指向描述错误代码含义的字符串的指针。

相关页面

教程:C 字符串

教程:C 字符串函数