这个c++语句怎么回事

来源:百度知道 编辑:UC知道 时间:2024/05/26 09:24:22
if((fp1 = fopen("input.txt","))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
老是提示:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\我的文档\Cpp1.cpp(27) : error C2001: newline in constant
D:\我的文档\Cpp1.cpp(28) : error C2143: syntax error : missing ')' before '{'
D:\我的文档\Cpp1.cpp(28) : error C2143: syntax error : missing ')' before '{'
D:\我的文档\Cpp1.cpp(28) : error C2143: syntax error : missing ')' before '{'
执行 cl.exe 时出错.

Cpp1.obj - 1 error(s), 0 warning(s)

("input.txt",")
这里面引号为奇数,第三个引号的问题

if((fp1 = fopen("input.txt","))==NULL)
这句错了
你看看是不是没写打开方式“r”,“w”之类的

其实最开始写的时候,最好还是分开来写。
FILE *fp1;
fp1=fopen("d:\\test.txt","w+");
if (fp1==NULL){
printf("Cannot open this file.\n");
exit( 0);

}

你没有写打开方式。

lz

if((fp1 = fopen("input.txt","))==NULL) 引号 数量不对呀!!
根据你现在的代码。看不出来其他的原因。

关于fopen() 的使用方法。下面的地址。。
http://hi.baidu.com/jeanwwq/blog/item/781138020fe86d82d53f7cc2.html

("input.txt",")这个引号数量貌似不对