C++ cstring strerror() 函数

定义和用法

strerror() 函数返回 C 风格的字符串,用于描述错误代码的含义。

strerror() 函数定义在 <cstring> 头文件中。

实例

输出各种错误信息:

cout << strerror(0) << "\n";
cout << strerror(1) << "\n";
cout << strerror(2) << "\n";
cout << strerror(3) << "\n";

亲自试一试

语法

strerror(int errcode);

参数

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

技术细节

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