請教COPY程式
麻煩各各大大能稍做解釋
讓不是對C很了解的我
能明白大概每行的指令在做什麼事情
以下是程式碼
#include <stdio.h>
#define BUFFERSIZE 1024
int main(int argc, char **argv) {
char *src, *dest;
FILE *s, *d;
char buffer[BUFFERSIZE];
if (argc>1) src = argv[1];
else { fprintf(stderr,"%s: no input file name",argv[0]); exit(1); }
if (argc>2) dest = argv[2];
else { fprintf(stderr,"%s: no output file name",argv[0]); exit(2); }
if ((s = fopen(src,"r"))==NULL) {
fprintf(stderr,"%s: can't open input file %s",argv[0],src); exit(3);
}
if ((d = fopen(dest,"w"))==NULL) {
fprintf(stderr,"%s: can't open output file %s",argv[0],dest); exit(4);
}
while (!feof(s)) {
if (fgets(buffer,BUFFERSIZE,s)) {
fputs(buffer,d);
}
}
fclose(s); fclose(d);
exit(0);
}