[求助]文件操作
【code】
#include <stdlib.h>
#include <stdio.h>
void main()
{
FILE *fp;
char ch,filename[10];
scanf("%s",filename);
if(fp==fopen(filename,"w")==NULL)
{
printf("cannot open file\n");
exit(0);
}
ch=getchar();
ch=getchar();
while(ch!='#')
{
fputc(ch,fp);
putchar(ch);
ch=getchar();
}
putchar(10);
fclose(fp);
}
[/code]
请问这个运行后怎么输入才不会显示cannot open file;