STRERROR(3)

NAME
perror, strerror, sys_errlist, sys_nerr - system error messages

SYNOPSIS
extern int errno;
extern char *sys_errlist[];
#include <stdio.h>
void
perror(const char *string);
char *
strerror(int errnum);

DESCRIPTION
The strerror() and perror() functions lookup the error message string affiliated with an error number.

The sterror() function accepts an error number argument errnum and returns a pointer to the corresponding message string.

The perror() function finds the error message corresponding to the current value of the global variable errno and writes it, followed by a new-line, to the stderr. If the argument string is non-NULL it is pre-appended to the message string and separated from it by a colon and space (‘: ’). If string is NULL only the error message string is printed.

The message strings can be accessed directly using the external character array sys_errlist. The external value sys_nerr contains a count of the messages in sys_errlist. The use of these variables is deprecated; strerror() should be used instead.

SEE ALSO
intro(2), psignal(3)

HISTORY
The strerror() and perror() functions are