求一个使用 wofstream 输出中文到文件的例子
C++ std::wofstream 类输出中内容到文件中失败,代码如下:
int main() {
fs::path currentPath = "D:\\XXX\\DDD\\a.txt";
//===================
std::vector<std::wstring> vec;
vec.push_back(L"1中");
vec.push_back(L"2中");
vec.push_back(L"3中");
std::wofstream ofs(currentPath);
auto it = vec.begin();
while (it != vec.end()) {
ofs << *it;
it++;
}
ofs.close();
return 0;
}