//设置代码页为简体中文,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));