diff options
author | Andreas Stieger <astieger@suse.com> | 2017-05-08 22:51:28 +0300 |
---|---|---|
committer | Andreas Stieger <astieger@suse.com> | 2017-05-08 23:01:35 +0300 |
commit | b1a1c67e3b9f7dad11d382e86166d0b008efa27f (patch) | |
tree | 5ff7382d857bcd6740b2fc264a68affb57f3d457 | |
parent | 0572d8a302b1f62f25c1559b0de74908550ab2c3 (diff) |
Print file IO error texts
-rw-r--r-- | src/main.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #ifndef _WIN32 #include <libgen.h> #endif @@ -62,7 +63,7 @@ int main(int argc, char** argv) fd = fopen(argv[i], "rb"); if (fd == NULL) { - printf("cannot open file: %s\n", argv[i]); + fprintf(stderr, "cannot open file: %s: %s\n", argv[i], strerror(errno)); return 1; } @@ -75,12 +76,12 @@ int main(int argc, char** argv) } if (ferror(fd)) { - printf("error while reading file: %s\n", argv[i]); + fprintf(stderr, "error while reading file: %s: %s\n", argv[i], strerror(errno)); return 1; } if (!feof(fd)) { - printf("not end of file?: %s\n",argv[i]); + fprintf(stderr, "not end of file?: %s: %s\n", argv[i], strerror(errno)); return 1; } |