Demo: can now read from stdin

master
Serge A. Zaitsev 14 years ago
parent d0d52f6847
commit 991ca5dd94

@ -57,11 +57,15 @@ int main(int argc, char *argv[]) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
if (strcmp(argv[1], "-") == 0) {
f = stdin;
} else {
f = fopen(argv[1], "r"); f = fopen(argv[1], "r");
if (f == NULL) { if (f == NULL) {
fprintf(stderr, "Failed to open file `%s`\n", argv[1]); fprintf(stderr, "Failed to open file `%s`\n", argv[1]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
}
while (1) { while (1) {
char buf[BUFSIZ]; char buf[BUFSIZ];

Loading…
Cancel
Save