.\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)strerror.3 6.6 (Berkeley) 03/05/91 .\" .TH STRERROR 3 "" .UC 4 .SH NAME perror, strerror, sys_errlist, sys_nerr \- system error messages .SH SYNOPSIS .nf .ft B extern int errno, sys_nerr; extern char *sys_errlist[]; #include void perror(const char *string); char *strerror(int errnum); .ft R .fi .SH DESCRIPTION .I Perror produces a short error message on the standard error file describing the last error encountered during a call to the system from a C program. If .I string is non-NULL, it is printed, followed by a colon, followed by a space, followed by the message and a new-line. Otherwise, just the message and the new-line are printed. Most usefully, the argument string is the name of the program which incurred the error. The error number is taken from the external variable .I errno (see .IR intro (2)), which is set when errors occur but not cleared when non-erroneous calls are made. .PP To simplify variant formatting of messages, the .I strerror function returns a pointer to the error message string mapped to the error number .IR errnum . .PP The message strings can be accessed directly using the external character array .IR sys_errlist . .I Sys_nerr is the total number of messages in the array. The use of these variables is deprecated; .I strerror should be used instead. .SH "SEE ALSO" intro(2), psignal(3)