//设置代码页为简体中文,936是简体中文的代码页。
std::locale loc1 = std::locale::global(std::locale(".936"));
//在这里使用 fstream、ifstream、ofstream
fstream binary_file(file_name ,ios::out|ios::binary|ios::trunc );
//恢复原来的代码页
std::locale::global(std::locale(loc1));
文件路径中文编码问题解决方案之一
本文介绍如何在C++中设置代码页为简体中文,并通过fstream进行文件操作的基本示例。重点突出代码实现及简体中文环境下的文件处理。

被折叠的 条评论
为什么被折叠?



