Next: strerror_r, Previous: strcspn, Up: Strings
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':
E2BIGEACCESEADDRINUSEEADVEAFNOSUPPORTEAGAINEALREADYEBADFEBADMSGEBUSYECHILDECOMMECONNABORTEDECONNREFUSEDEDEADLKEDESTADDRREQEEXISTEDOMEFAULTEFBIGEHOSTDOWNEHOSTUNREACHEIDRMEINPROGRESSEINTREINVALEIOEISCONNEISDIRELIBACCELIBBADELIBEXECELIBMAXELIBSCN.lib section in a.out corrupted
EMFILEEMLINKEMSGSIZEEMULTIHOPENAMETOOLONGENETDOWNENETUNREACHENFILEENODEVENOENTENOEXECENOLCKENOLINKENOMEMENOMSGENONETENOPKGENOPROTOOPTENOSPCENOSRENOSTRENOSYSENOTBLKENOTCONNENOTDIRENOTEMPTYENOTSOCKENOTSUPENOTTYENXIOEPERMEPIPEEPROTOEPROTOTYPEEPROTONOSUPPORTERANGEEREMOTEEROFSESHUTDOWNESOCKTNOSUPPORTESPIPEESRCHESRMNTETIMEETIMEDOUTETXTBSYEXDEV
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.