为啥fopen一直打开文件失败
int main(){
FILE *fp1,*fp2;
char c;
if((fp1=fopen("file1.txt","w"))==NULL);
{
printf("打开文件失败");
exit(0);
}
printf("请输入字符");
while((c=getchar())!='\n')
{
fputs(c,fp1);
fclose(fp1);
if((fp2=fopen("file1.txt","r"))==NULL)
{
printf("打开文件失败");
exit(0);
}
}
printf("输出字符\n");
while((c=putchar(fp2))!=EOF)
{
putchar(c);
printf("\n");
fclose(fp2);
}
}
这是代码!求解答。。。。