1.\" Copyright (c) 1980, 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)strerror.3 6.8 (Berkeley) 04/19/91 7.\" 8.Dd 9.Dt STRERROR 3 10.Os BSD 4 11.Sh NAME 12.Nm perror , 13.Nm strerror , 14.Nm sys_errlist , 15.Nm sys_nerr 16.Nd system error messages 17.Sh SYNOPSIS 18.Vt extern int errno; 19.Vt extern char *sys_errlist[]; 20.Fd #include <stdio.h> 21.Ft void 22.Fn perror "const char *string" 23.Ft char * 24.Fn strerror "int errnum" 25.Sh DESCRIPTION 26The 27.Fn strerror 28and 29.Fn perror 30functions lookup the error message string affiliated with an 31error number. 32.Pp 33The 34.Fn sterror 35function accepts an error number argument 36.Fa errnum 37and 38returns a pointer to the corresponding 39message string. 40.Pp 41The 42.Fn perror 43function finds the error message corresponding to the current 44value of the global variable 45.Va errno 46and writes it, followed by a new-line, to the 47.Em stderr . 48If the argument 49.Fa string 50is 51.Pf non- Dv NULL 52it is pre-appended to the message 53string and separated from it by 54a colon and space 55.Pq Ql \&:\ \& . 56If 57.Fa string 58is 59.Dv NULL 60only the error message string is printed. 61.Pp 62The message strings can be accessed directly using the external 63character array 64.Fa sys_errlist . 65The external value 66.Fa sys_nerr 67contains a count of the messages in 68.Fa sys_errlist . 69The use of these variables is deprecated; 70.Fn strerror 71should be used instead. 72.Sh SEE ALSO 73.Xr intro 2 , 74.Xr psignal 3 75.Sh HISTORY 76The 77.Fn strerror 78and 79.Fn perror 80functions are 81.Ud . 82