diff options
author | Serge A. Zaitsev <devnull@localhost> | 2010-11-17 12:05:29 +0200 |
---|---|---|
committer | Serge A. Zaitsev <devnull@localhost> | 2010-11-17 12:05:29 +0200 |
commit | 991ca5dd940ab9f1deb492b3c8cec4692c2f7099 (patch) | |
tree | 4abd6211a760d3427f33f3a2e65a2e7587e617fa | |
parent | d0d52f68478f5cf6cb19629968dfe07c3ca040a7 (diff) |
Demo: can now read from stdin
-rw-r--r-- | demo.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -57,10 +57,14 @@ int main(int argc, char *argv[]) { exit(EXIT_SUCCESS); } - f = fopen(argv[1], "r"); - if (f == NULL) { - fprintf(stderr, "Failed to open file `%s`\n", argv[1]); - exit(EXIT_FAILURE); + if (strcmp(argv[1], "-") == 0) { + f = stdin; + } else { + f = fopen(argv[1], "r"); + if (f == NULL) { + fprintf(stderr, "Failed to open file `%s`\n", argv[1]); + exit(EXIT_FAILURE); + } } while (1) { |