编程实现 copy 命令,执行格式:copy file1 file2 file3 功能:将 file1、file2 两文件的内容合并拷入 file3
1个回答
展开全部
int main(int argc, char *argv[])
{
char F1[20] = {0};
char F2[20] = {0};
char F3[20] = {0};
char ch;
FILE *pf1, *pf2, *pf3;
printf("intput the two source files name :");
scanf("%s %s",F1,F2);
printf("input the des file name: ");
scanf("%s",F3);
printf("%s %s %s",F1,F2,F3);
if(NULL == (pf1 = fopen(F1,"rb"))) return 0;
if(NULL == (pf2 = fopen(F2,"rb"))) return 0;
if(NULL == (pf3 = fopen(F3,"wb+"))) return 0;
while((ch=fgetc(pf1))!=EOF)
putc(ch,pf3);
while((ch=fgetc(pf2))!=EOF)
putc(ch,pf3);
fclose(pf1);
fclose(pf2);
fclose(pf3);
{
char F1[20] = {0};
char F2[20] = {0};
char F3[20] = {0};
char ch;
FILE *pf1, *pf2, *pf3;
printf("intput the two source files name :");
scanf("%s %s",F1,F2);
printf("input the des file name: ");
scanf("%s",F3);
printf("%s %s %s",F1,F2,F3);
if(NULL == (pf1 = fopen(F1,"rb"))) return 0;
if(NULL == (pf2 = fopen(F2,"rb"))) return 0;
if(NULL == (pf3 = fopen(F3,"wb+"))) return 0;
while((ch=fgetc(pf1))!=EOF)
putc(ch,pf3);
while((ch=fgetc(pf2))!=EOF)
putc(ch,pf3);
fclose(pf1);
fclose(pf2);
fclose(pf3);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询