VC2012汉语言件流操作

VC2012中文件流操作
本帖最后由 lxymine 于 2013-02-26 15:44:30 编辑
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string s="ifile.txt";
ifstream map_file(s.c_str());
if(!map_file)
{
cout<<"no map_file"<<endl;
}
return 0;
}
上面的程序在VC6.0上运行是可以打开ifile.txt,而在VC2012中却不能打开ifile.txt文件,运行了if语句中的内容,VC2012中应该如何正确打开ifile.txt呢?
VC2012 文件流操作

------解决方案--------------------

int main()
{
string s="1.txt";
ifstream map_file(s.c_str());
if(!map_file)
{
cout<<"no map_file"<<endl;
}
else
{
cout<<"abcd"<<endl;
}
system("pause");
return 0;
}

我输出的是abcd,你应该是txt文件放错地方了。