将一个磁盘文件中的信息复制到另一个磁盘文件中去,结果为什么是cannot open the file2
#include <stdio.h>#include <stdlib.h>
void main()
{
FILE *fp1;
FILE *fp2;
char ch;
if((fp1=fopen("1.txt","r"))==NULL)
{
printf("cannot open the file1!\n");
exit(0);
}
if((fp2=fopen("2.txt","W"))==NULL)
{
printf("cannot open the file2!\n");
exit(0);
}
ch=fgetc(fp1);
while(!feof(fp1))
{
fputc(ch,fp2);
putchar(ch);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
}