perror(3C)
_________________________________________________________________
perror function
Print a string and the last error message.
_________________________________________________________________
Calling Sequence
char *string;
perror(string);
extern int errno;
extern char *syserrlist[];
extern int sysnerr;
Description
The perror function prints out a string and the last error
message on the error file. If the argument is the null string,
perror does not print a colon or error number.
The array of message strings sys_errlist simplifies variant
formatting of messages. Errno can be used as an index in this
table to get the message string without the new-line. Sys_nerr
is the largest message number provided for in the table; check
it, since new error codes may be added to the system before they
are added to the table.
Returns
The perror function does not return a value.
Related Functions
See also the ferror macro.
Example
/* Program test for the perror() function */
#include <stdio.h>
FILE *fopen();
main(argc, argv)
int argc;
char *argv[];
{
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
perror(3C)
if (fopen( argv[1], "w") == NULL) {
perror(argv[1]);
exit(0);
}
}
If you call the program test with the filename c.temp when you do
not have access permission to c.temp, you will receive this
message:
c.temp:0221215 Error EACCES(13) -- Permission denied.
BUGS
To use the sys_errlist, errno must be defined in
/usr/include/sys/errno.h. Thus errors generated by the C
compiler cannot simply index into sys_errlist; they must be
passed to perror, which looks up error messages in the file
/etc/ermes.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)