问题
单项选择题
若磁盘上已存在某个文本文件,其全路径文件名为d:\ncre\test.txt,下列语句中不能打开该文件的是
A.ifstream file("d:\ncre\testxt");
B.ifstream file("d:\\ncre\\testxt");
C.ifstream file;filopen("d:\\ncre\\testxt");
D.ifstream* pFile=new ifstream("d:\\ncre\\testxt");
答案
参考答案:A
解析: 本题考查的知识点是转义字符。在C++的字符常量或字符串中,以“\”开头的一系列字符被看作一个特殊的字符,即转义字符。要表示'\'字符时,必须使用转义字符'\\'。故本题应该选择A。