#include <myhead.h>
int main(int argc, const char *argv[])
{
if(argc!=3)
{
printf("外部参数错误");
return -1;
}
FILE *fp1,*fp2;
fp1=fopen("./1.txt","r");
if(fp1==NULL)
{
perror("fp1");
return -1;
}
fp2=fopen("./2.txt","w");
if(fp2==NULL)
{
perror("fp2");
return -1;
}
char buf;
while(1)
{
buf=fgetc(fp1);
if(buf==EOF)
{
break;
}
fputc(buf,fp2);
}
fclose(fp1);
fclose(fp2);
fopen("./2.txt","r");
if(fp2==NULL)
{
perror("fp2");
return -1;
}
char rev;
while(1)
{
rev=fgetc(fp2);
if(rev==EOF)
{
break;
}
fputc(rev,stdout);
}
fclose(fp2);
return 0;
}
fgetc和fputc拷贝文件
最新推荐文章于 2024-10-31 15:49:24 发布