strerror
---convert error number to string#include <string.h> char *strerror(int errnum);Description
strerror
converts the error number errnum into a
string. The value of errnum is usually a copy of errno
.
If errnum
is not a known error number, the result points to an
empty string.
This implementation of strerror
prints out the following strings
for each of the values defined in `errno.h
':
E2BIG
EACCES
EADV
EAGAIN
EBADF
EBADMSG
EBUSY
ECHILD
ECOMM
EDEADLK
EEXIST
EDOM
EFAULT
EFBIG
EIDRM
EINTR
EINVAL
EIO
EISDIR
ELIBACC
ELIBBAD
ELIBEXEC
ELIBMAX
ELIBSCN
.lib
section in a.out corrupted
EMFILE
EMLINK
EMULTIHOP
ENFILE
ENODEV
ENOENT
ENOEXEC
ENOLCK
ENOLINK
ENOMEM
ENOMSG
ENONET
ENOPKG
ENOSPC
ENOSR
ENOSTR
ENOTBLK
ENOTDIR
ENOTTY
ENXIO
EPERM
EPIPE
EPROTO
ERANGE
EREMOTE
EROFS
ESPIPE
ESRCH
ESRMNT
ETIME
ETXTBSY
EXDEV
Returns
This function returns a pointer to a string. Your application must
not modify that string.
Portability
ANSI C requires strerror
, but does not specify the strings used
for each error number.
Although this implementation of strerror
is reentrant, ANSI C
declares that subsequent calls to strerror
may overwrite the
result string; therefore portable code cannot depend on the reentrancy
of this subroutine.
This implementation of strerror
provides for user-defined
extensibility. errno.h
defines __ELASTERROR, which can be
used as a base for user-defined error values. If the user supplies a
routine named _user_strerror
, and errnum passed to
strerror
does not match any of the supported values,
_user_strerror
is called with errnum as its argument.
_user_strerror
takes one argument of type int, and returns a
character pointer. If errnum is unknown to _user_strerror
,
_user_strerror
returns NULL. The default _user_strerror
returns NULL for all input values.
strerror
requires no supporting OS subroutines.