C++ 宽字符

今天在VS2008上些程序时遇到如下问题:
void ReadFile_Name()
{
	//打开文件,并判断是否打开成功
	ifstream outfile("E:\\HEWEI\\PhpCollab\\HandleString\\Name.txt");
	//outfile.open("E:\\HEWEI\\PhpCollab-任务\\HandleString\\Name.txt");
	if(! outfile)
	{
		cerr << "The file :Name.txt Can't open!!";
		exit(1);
	}
	//从打开的文件中读取一行,并进行处理 
	string s;  
	while( getline(outfile,s) )
	{    
		cout << "Read from file: " << s << endl; 
	}
}


开始时用:outfile.open("E:\\HEWEI\\PhpCollab-任务\\HandleString\\Name.txt");
无论如何也打不开文件,换用outfile.open("E:\\HEWEI\\PhpCollab\\HandleString\\Name.txt");
后便可以打开。

原来VS2008字符串是宽字符串,不可用汉字,汉字和字符串占用的字节数不一样。

你可能感兴趣的:(C++,c,C#)