编程语言
首页 > 编程语言> > C++ errno

C++ errno

作者:互联网

文章目录

一、 errno 介绍

#define errno   (*_errno())
#define _doserrno   (*__doserrno())
#define _sys_errlist (__sys_errlist())
#define _sys_nerr (*__sys_nerr())

二、错误信息输出

	FILE* pf = fopen("test.txt", "r");
	if (!pf) {
		perror("perror");
		printf("strerror: %s\n", strerror(errno));
		printf( _strerror("_strerror") );
	}
perror: No such file or directory
strerror: No such file or directory
_strerror: No such file or directory

三、错误码表查询

错误码 含义
NULL 0 No error
EPERM 1 Operation not permitted
ENOENT 2 No such file or directory
ESRCH 3 No such process
EINTR 4 Interrupted function call
EIO 5 Input/output error
ENXIO 6 No such device or address
E2BIG 7 Arg list too long
ENOEXEC 8 Exec format error
EBADF 9 Bad file descriptor
ECHILD 10 No child processes
EAGAIN 11 Resource temporarily unavailable
ENOMEM 12 Not enough space
EACCES 13 Permission denied
EFAULT 14 Bad address
/ 15 Unknown error
EBUSY 16 Resource device
EEXIST 17 File exists
EXDEV 18 Improper link
ENODEV 19 No such device
ENOTDIR 20 Not a directory
EISDIR 21 Is a directory
EINVAL 22 Invalid argument
ENFILE 23 Too many open files in system
EMFILE 24 Too many open files
ENOTTY 25 Inappropriate I/O control operation
/ 26 Unknown error
EFBIG 27 File too large
ENOSPC 28 No space left on device
ESPIPE 29 Invalid seek
EROFS 30 Read-only file system
MLINK 31 Too many links
EPIPE 32 Broken pipe
EDOM 33 Domain error
ERANGE 34 Result too large
/ 35 Unknown error
EDEADLK 36 Resource deadlock avoided
/ 37 Unknown error
ENAMETOOLONG 38 Filename too long
ENOLCK 39 No locks available
ENOSYS 40 Function not implemented
ENOTEMPTY 41 Directory not empty
EILSEQ 42 Illegal byte sequence

标签:No,errno,strerror,C++,sys,error,such
来源: https://blog.51cto.com/u_15239535/2836982