用fscanf和fprintf实现拷贝:
#include <stdio.h>
int main(int argc, const char *argv[])
{
if(argc < 2)
{
printf("命令行未传参,请传入文件名\n");
return -1;
}
FILE* fop = fopen(argv[1],"r");
if(NULL == fop)
{
perror("fopen\n");
return -1;
}
FILE* new = fopen(argv[2],"w");
int size = 0;
char c;
while(fscanf(fop,"%c",&c) != -1)
{
fprintf(new,"%c",c);
size++;
}
printf("文件大小:%d,文件复制成功\n",size);
fclose(fop);
fclose(new);
return 0;
}
```第二题不会