文件操作老是报错,不知道是什么原因
#include <stdio.h>#include <stdlib.h>
#include <string.h>
int main()
{
FILE *fp1,*fp2;
int i;
char ch;
if((fp1=fopen("e://1.txt","r"))==NULL)
{
printf("File open error\n");
exit(0);
}
if((fp1=fopen("e://2.txt","w"))==NULL)
{
printf("File open error\n");
exit(0);
}
while(1)
{
ch=fgetc(fp1);
if(feof(fp1))
break;
fputc(ch,fp2);
}
if(fclose(fp1))
{
printf("Cant not close the file\n");
exit(0);
}
if(fclose(fp2))
{
printf("Cant not close the file\n");
exit(0);
}
return 0;
}