首页 新闻 会员 周边 捐助

使用fgets和fputs实现cp,怎么失败了啊

0
[已关闭问题] 关闭于 2023-04-07 13:22

include <stdio.h>

int main(int argc,const char* argv[])
{
if(argc != 3)
{
printf("Usage: %s PathName PathName\n",argv[0]);
return -1;
}

FILE *fp1 = fopen(argv[1],"r");
if(fp1 == NULL)
{
	perror("fopen");
	return -1;
}

FILE *fp2 = fopen(argv[2],"w");
if(fp2 != NULL)
{
	fclose(fp1);
	perror("fopen");
	return -1;
}

char buf[128] = {0};
while(fgets(buf,sizeof(buf)-1,fp1)!=NULL)
fputs(buf,fp2);


fclose(fp1);
fclose(fp2);

return 0;

}

景哈哈的主页 景哈哈 | 初学一级 | 园豆:8
提问于:2022-09-06 21:03
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册