Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This code simulates how the Unix cat command works
- #include <stdio.h>
- main(int argc, char *argv[])
- {
- int i;
- FILE *fp;
- int c;
- for(i = 1; i < argc; i++)
- {
- fp = fopen(argv[i], "r");
- if(fp == NULL)
- {
- fprintf(stderr, "cat: can't open %s\n", argv[i]);
- continue;
- }
- while((c = getc(fp)) != EOF)
- putchar(c);
- fclose(fp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement