Created
May 14, 2011 14:59
-
-
Save monzou/972298 to your computer and use it in GitHub Desktop.
cat w/ stdio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char const *argv[]) | |
{ | |
int i; | |
for (i = 1; i < argc; i++) { | |
FILE *f = fopen(argv[i], "r"); | |
int c; | |
if (!f) { | |
perror(argv[i]); | |
exit(1); | |
} | |
while ((c = fgetc(f)) != EOF) { | |
if (putchar(c) < 0) { | |
exit(1); | |
} | |
} | |
fclose(f); | |
} | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment