[求助]一个文件输入程序有问题
#include "stdio.h"main()
{
FILE * fp;
char ch;
if((fp=fopen("file1.txt","w")==NULL))
{
printf("cannot open file\n");
exit(0);
}
while((ch=getchar())!='\n')
fputc(ch,fp);
fclose(fp);
}
运行以后我输入一些字符,结果却是NULL PIONTER ASSIGNMENT请问是怎么回事啊
----------------解决方案--------------------------------------------------------
if((fp=fopen("file1.txt","w")==NULL))
改成
if((fp=fopen("file1.txt","w"))==NULL)
----------------解决方案--------------------------------------------------------
我真是态粗心了,谢谢!!!
----------------解决方案--------------------------------------------------------