可以通过以下代码,获取所有的错误码信息:
#include <string.h> /* for strerror */
#include <errno.h>
#include <stdio.h>
int main(int argc, char ** argv)
{
int i = 0;
for(i = 0; i < 256; i++)
printf("errno-%02d is: %s\n", i, strerror(i));
return 0;
}
编译此程序用命令: gcc -Wall strerror.c
执行程序:
./a.out
输出如下:
errno-00 is: Success
errno-01 is: Operation not permitted
errno-02 is: No such file or directory
errno-03 is: No such process
errno-04 is: Interrupted system call
errno-05 is: Input/output error
errno-06 is: No such device or address
errno-07 is: Argument list too long
errno-08 is: Exec format error
errno-09 is: Bad file descriptor
errno-10 is: No child processes
errno-11 is: Resource temporarily unavailable
errno-12 is: Cannot allocate memory
errno-13 is: Permission denied
errno-14 is: Bad address
errno-15 is: Block device required
errno-16 is: Device or resource busy
errno-17 is: File exists
errno-18 is: Invalid cross-device link
errno-19 is: No such device
errno-20 is: Not a directory
errno-21 is: Is a directory
errno-22 is: Invalid argument
errno-23 is: Too many open files in system