1.6 示例strerror和perror
file/testerror.c
1 #include "apue.h" 2 #include <errno.h> 3 int 4 main(int argc, char *argv[]) 5 { 6 fprintf(stderr, "EACCES: %s\n", strerror(EACCES)); 7 errno = ENOENT; 8 perror(argv[0]); 9 exit(0); 10 }
file/testerror.c
1 #include "apue.h" 2 #include <errno.h> 3 int 4 main(int argc, char *argv[]) 5 { 6 fprintf(stderr, "EACCES: %s\n", strerror(EACCES)); 7 errno = ENOENT; 8 perror(argv[0]); 9 exit(0); 10 }