69,373
社区成员
发帖
与我相关
我的任务
分享
1 #include<stdio.h>
2 int main(int argc, char *argv[])
3 {
4 FILE *fp;
5 void filecopy(FILE *, FILE *);
6 if(argc == 1)
7 filecopy(stdin,stdout);
8 else
9 while(--argc >0)
10 if((fp = fopen(*++argv,"r") == NULL))
11 {
12 printf("cat:can't open %s",*argv);
13 return 1;
14 }
15 else
16 {
17 filecopy(fp, stdout);
18 fclose(fp);
19
20 }
21 return 0;
22 }
23
24 void filecopy(FILE *ifp, FILE *ofp)
25 {
26 int c;
27 while((c = getc(ifp)) != EOF)
28 putc(c,ofp);
29 }
30
31