1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <console.h> 4 5 int main(int argc, char *argv[]) 6 { 7 FILE *f; 8 int i; 9 int len; 10 char buf[4096]; 11 12 if (argc < 2) { 13 fprintf(stderr, "Usage: %s filename...\n", argv[0]); 14 return 1; 15 } 16 17 for (i = 1; i < argc; i++) { 18 f = fopen(argv[i], "r"); 19 if (!f) { 20 fprintf(stderr, "%s: %s: file not found\n", argv[0], argv[i]); 21 return 1; 22 } 23 24 while ((len = fread(buf, 1, sizeof buf, f)) > 0) 25 fwrite(buf, 1, len, stdout); 26 27 fclose(f); 28 } 29 30 return 0; 31 } 32