1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
/* usage: append a b c |
/* usage: append a b c |
3 |
equivalent to cat a b >> c |
equivalent to cat a b >> c |
4 |
if only cat were binary... but by some wonderful dos like deicision, |
if only cat were binary... but by some wonderful dos like deicision, |
5 |
it is not under cygnus.. |
it is not under cygnus.. |
6 |
*/ |
*/ |
7 |
main(int argc,char *argv[]) |
main(int argc,char *argv[]) |
8 |
{ int i; |
{ int i; |
9 |
FILE *out ; |
FILE *out ; |
10 |
if (argc < 2) return 0; |
if (argc < 2) return 0; |
11 |
out = fopen(argv[argc-1],"a+b"); |
out = fopen(argv[argc-1],"a+b"); |
12 |
if (out == 0) |
if (out == 0) |
13 |
{ perror("cant open"); return 1; } |
{ perror("cant open"); return 1; } |
14 |
for (i=1; i < argc-1 ; i++) |
for (i=1; i < argc-1 ; i++) |
15 |
{ |
{ |
16 |
FILE *fp = fopen(argv[i],"rb"); |
FILE *fp = fopen(argv[i],"rb"); |
17 |
int ch; |
int ch; |
18 |
if (fp == 0) |
if (fp == 0) |
19 |
{ perror("cant open"); return 1; } |
{ perror("cant open"); return 1; } |
20 |
while (1) { |
while (1) { |
21 |
ch =getc(fp); |
ch =getc(fp); |
22 |
if (ch == EOF && feof(fp)) |
if (ch == EOF && feof(fp)) |
23 |
{ fclose(fp); |
{ fclose(fp); |
24 |
break; |
break; |
25 |
} else |
} else |
26 |
putc(ch,out); |
putc(ch,out); |
27 |
|
|
28 |
} |
} |
29 |
} |
} |
30 |
fclose(out); |
fclose(out); |
31 |
return 0; |
return 0; |
32 |
} |
} |
33 |
|
|
34 |
|
|