strerror函数

来源:互联网 发布:网络文明传播实施方案 编辑:程序博客网 时间:2024/05/06 03:05

1 题目

测试strerror函数。

2 代码:

执行环境:VC++6.0

 

[cpp] view plaincopy
  1. #include <stdio.h>  
  2. #include <string.h>  
  3. #include <errno.h>  
  4.   
  5. void main()  
  6. {  
  7.     int errnum;  
  8.   
  9.     for(errnum = 1; errnum < 43; errnum++)  
  10.         printf("error %d : %s/n", errnum, strerror(errnum));  
  11.     printf("/n");  
  12. }  

执行结果:

error 1 : Operation not permitted

error 2 : No such file or directory

error 3 : No such process

error 4 : Interrupted function call

error 5 : Input/output error

error 6 : No such device or address

error 7 : Arg list too long

error 8 : Exec format error

error 9 : Bad file descriptor

error 10 : No child processes

error 11 : Resource temporarily unavailable

error 12 : Not enough space

error 13 : Permission denied

error 14 : Bad address

error 15 : Unknown error

error 16 : Resource device

error 17 : File exists

error 18 : Improper link

error 19 : No such device

error 20 : Not a directory

error 21 : Is a directory

error 22 : Invalid argument

error 23 : Too many open files in system

error 24 : Too many open files

error 25 : Inappropriate I/O control operation

error 26 : Unknown error

error 27 : File too large

error 28 : No space left on device

error 29 : Invalid seek

error 30 : Read-only file system

error 31 : Too many links

error 32 : Broken pipe

error 33 : Domain error

error 34 : Result too large

error 35 : Unknown error

error 36 : Resource deadlock avoided

error 37 : Unknown error

error 38 : Filename too long

error 39 : No locks available

error 40 : Function not implemented

error 41 : Directory not empty

error 42 : Illegal byte sequence

Press any key to continue

3 资料:

Errno.h中对error num 的定义:

/* Error Codes */

#define EPERM           1

#define ENOENT          2

#define ESRCH           3

#define EINTR           4

#define EIO             5

#define ENXIO           6

#define E2BIG           7

#define ENOEXEC         8

#define EBADF           9

#define ECHILD          10

#define EAGAIN          11

#define ENOMEM          12

#define EACCES          13

#define EFAULT          14

#define EBUSY           16

#define EEXIST          17

#define EXDEV           18

#define ENODEV          19

#define ENOTDIR         20

#define EISDIR          21

#define EINVAL          22

#define ENFILE          23

#define EMFILE          24

#define ENOTTY          25

#define EFBIG           27

#define ENOSPC          28

#define ESPIPE          29

#define EROFS           30

#define EMLINK          31

#define EPIPE           32

#define EDOM            33

#define ERANGE          34

#define EDEADLK         36

#define ENAMETOOLONG    38

#define ENOLCK          39

#define ENOSYS          40

#define ENOTEMPTY       41

#define EILSEQ          42

0 0
原创粉丝点击