33,008
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFERSIZE 1000
int main(int argc, char *argv[])
{
if (argc<3)
{
printf("参数不足\n");
return 0;
}
//int cnt=argc-1;
int i;
FILE *fp;
if(NULL==(fp=fopen(argv[1],"a")))
{
printf("目标文件打开失败!");
return 0;
}
fprintf(fp,"%s","\n");
FILE *fpSRC;
for (i=2;i<argc;i++)
{
if(NULL==(fpSRC=fopen(argv[i],"r")))
{
printf("源文件打开失败!");
return 0;
}
char temp[BUFFERSIZE+1];
while (fgets(temp,BUFFERSIZE,fpSRC))
{
fprintf(fp,"%s\n",temp);
}
fclose(fpSRC);
}
printf("内容复制成功!\n");
fclose(fp);
return 0;
}