January 2003
Intermediate to advanced
624 pages
14h 5m
English
Errors generated by the failure of a system call or library function, can be displayed using the perror or strerror library function calls (see “Managing Failures” Section 1.5, “Managing System Call Failures”). For example, the error messages returned by strerror on a Linux system can be displayed in their entirety using Program B.1.
Example B.1. Displaying strerror messages.
File : errors.cxx
| #include <iostream>
| #include <cstring>
| #include <errno.h>
| extern int sys_nerr;
+ using namespace std;
| int
| main( ){
| for (int err=0; err < sys_nerr; ++err )
| cout << err << '\t' << strerror(err) << endl;
10 return 0;
| }
As the output of the program will fill more than one screen, it may be helpful to redirect ...
Read now
Unlock full access