Format
#include <string.h>
char *strerror(int errnum);
Language Level: ANSI
Threadsafe: Yes.
Description
The strerror() function maps the error number in errnum to an error message string.
Return Value
The strerror() function returns a pointer to the string. It does not return a NULL value. The value of errno may be set to ECONVERT (conversion error).
Example that uses strerror()
This example opens a file and prints a runtime error message if an error occurs.
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main(void)
{
FILE *stream;
if ((stream = fopen("mylib/myfile", "r")) == NULL)
printf(" %s \n", strerror(errno));
}
/* This is a program fragment and not a complete function example */
Related Information