if( ( save_file = fopen("/home/han/save.txt","w") ) == NULL);
{
fprintf(stderr,"%s\n","filed to open file");
exit(1);
}
/*
save_file = fopen("/home/han/save.txt","w");
if(save_file == NULL)
{
fprintf(stderr,"%s\n","filed to open file");
exit(1);
}
*/
注释部分代码和前面的代码有区别吗?为什么上面的代码总是输出filed to open file而注释部分的代码是正常的啊!!!???
if( ( save_file = fopen("/home/han/save.txt","w") ) == NULL); 多了分号
如果分好改了,还不对;查看一下是否是TXT格式或者看一下文件权限
( save_file = fopen("/home/han/save.txt","w") ) 这段如果直接放在if里面他的返回结果只能是ture或FALSE