若磁盘上已存全路径文件名为c:\ctest\test.txt的文件,下面语句中不能打开该文件的是( )。

admin2012-12-29  28

问题 若磁盘上已存全路径文件名为c:\ctest\test.txt的文件,下面语句中不能打开该文件的是(             )。

选项 A、ifstream *pFile=new ifstream(“c:\\ctest\\test.txt”);
B、ifstream file(“c:\\ctest\\test.txt”);
C、ifstream file;file.open(“c:\\ctest\\test.txt”);
D、ifstream file(“c:\ctest\test.txt”);

答案D

解析 由于“\”在C++中用来定义转义字符,所以必须对文件名字符串中的“\”进行转义,所以只有选项D)不正确。
转载请注明原文地址:https://kaotiyun.com/show/VuVp777K
0

最新回复(0)