fstream如何打开中文路径 [C/C++]

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://yzyanchao.blogbus.com/logs/35621328.html

      VS2005开始(似乎),用ofstream打开中文路径名会出现乱码问题,解决方法为:

std::locale loc = std::locale::global(std::locale(""));
std::ofstream fout(FilePath);

//do some work here

fout.close();
std::locale::global( loc );

不加最后一句,cout回无法输出中文字符。

原文地址:https://www.cnblogs.com/iapp/p/3631852.html