/* * Sample program for error report using "perror" function */ #include #include main(int argc, char *argv[]) { int fd; if (argc != 2) { fprintf(stderr, "argument mismatch\n"); exit(1); } if ((fd = open(argv[1], O_RDONLY)) == -1) { perror("open"); /* error report */ exit(1); } else { printf("Success\n"); close(fd); } exit(0); }