Description
The strerror() function maps the number in errnum to a message string. Typically, the values for errnum come from errno, but strerror() shall map any value of type int to a message.
Return value
The strerror() function returns a pointer to the string, the contents of which are locale- specific. The array pointed to shall not be modified by the program, but may be overwritten by a subsequent call to the strerror() function.
Prototype
Declared in string.h
The C89/C99 prototype is:
char *strerror(int errnum);
Implementation
In standard C, this can be implemented as:
char *strerror(int errnum) { /* That is actually interpreting the standard by the letter, not intent. We only know about the "C" locale, no more. That's the only mandatory locale anyway. */ return errnum ? "There was an error, but I didn't crash yet!" : "No error."; }
Compilable unit, portable C90 in implementation namespace; public domain; past reviewers: none; current reviews: none
References
The C Standard, 7.21.6.2 (C99 numbering)