C语言strerror()函数:返回错误原因的描述字符串
2015-12-21 11:34
246 查看
相关函数:perror
头文件:#include <string.h>
定义函数:char * strerror(int errnum);
函数说明:strerror()用来依参数errnum 的错误代码来查询其错误原因的描述字符串, 然后将该字符串指针返回.
返回值:返回描述错误原因的字符串指针.
范例:
/* 显示错误代码0 至9 的错误原因描述 */
#include <string.h>
main()
{
int i;
for(i = 0; i < 10; i++)
printf("%d : %s\n", i, strerror(i));
}
执行:
0 : Success
1 : Operation not permitted
2 : No such file or directory
3 : No such process
4 : Interrupted system call
5 : Input/output error
6 : Device not configured
7 : Argument list too long
8 : Exec format error
9 : Bad file descriptor
头文件:#include <string.h>
定义函数:char * strerror(int errnum);
函数说明:strerror()用来依参数errnum 的错误代码来查询其错误原因的描述字符串, 然后将该字符串指针返回.
返回值:返回描述错误原因的字符串指针.
范例:
/* 显示错误代码0 至9 的错误原因描述 */
#include <string.h>
main()
{
int i;
for(i = 0; i < 10; i++)
printf("%d : %s\n", i, strerror(i));
}
执行:
0 : Success
1 : Operation not permitted
2 : No such file or directory
3 : No such process
4 : Interrupted system call
5 : Input/output error
6 : Device not configured
7 : Argument list too long
8 : Exec format error
9 : Bad file descriptor
相关文章推荐
- C++异常规范
- effective c++学习笔记
- C++ 多态之继承2-继承的相关基础
- c++在vs2012中链接mysql操作
- C++模板:函数模板和模板函数 .
- 静态检测工具-cppcheck
- OC语言-02面向对象的三大特性
- 解决C/C++ 头文件相互包含 问题的方法
- [转][C/C++] 怎样不用中间变量temp 实现两个数交换
- C++常用库函数
- C++中public,protected,private访问
- 高质量C++编程之前言
- C++ 引用 指针 使用举例
- C++ 编译器相关“#pragma once”
- 【C++】深度探索C++对象模型之类存储
- 语言c++(index)
- C++命名空间
- C++编程实践: 抽象基类
- 嵌入式c语言面试题
- 试题03 数素数