代码
#include<myhead.h>
int main(int argc, const char *argv[])
{
if(argc!=3){
perror("错误信息\n");
return -1;
}
FILE *fp1 = fopen("./1.txt","r");
if(fp1 == NULL)
{
perror("错误信息:");
return -1;
}
FILE *fp2 = fopen("./2.txt","w");
if(fp2 == NULL)
{
perror("错误信息:");
return -1;
}
char buff[1024];
while(fgets(buff,sizeof(buff),fp1)!=NULL)
{
fputs(buff,fp2);
}
fclose(fp1);
fclose(fp2);
fp2 = fopen("./2.txt","r");
if(fp2 == NULL)
{
perror("错误信息:");
return -1;
}
char rev[1000];
while(fgets(rev,sizeof(rev),fp2)!=NULL)
{
fputs(rev,stdout);
}
fclose(fp2);
return 0;
}