On this page
strerror
Prev: strstr | Up: string.h | Next: strdup
Rel: string.h, stdlib.h & string.h Guide
Ref: cppreference — strerror
Tags: #public #prog #c #stdlib #string #tier/standard
Include
#include <string.h>
Signature & Overview
char *strerror(int errnum);
Maps an errno integer to a human-readable error message string.
Notes & Pitfalls
- NOT thread-safe (returns a static buffer): In multi-threaded POSIX code, use
strerror_r().
Example
#include <assert.h>
#include <errno.h>
#include <string.h>
int main(void) {
const char *msg = strerror(ENOENT);
assert(msg != NULL && strlen(msg) > 0);
}
Linked from
Related notes
- tuts/c/stdlib/string/strdup Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strstr Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string
- tuts/c/stdlib/stdlib_and_string_h Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/string/memchr shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memcmp shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memcpy shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memmove shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memset shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strcat shared tags: #c, #prog, #stdlib, #string, #tier