16
如何将wstring转换为string?
问题是如何将wstring转换为string? 我有下一个例子: #include <string> #include <iostream> int main() { std::wstring ws = L"Hello"; std::string s( ws.begin(), ws.end() ); //std::cout <<"std::string = "<<s<<std::endl; std::wcout<<"std::wstring = "<<ws<<std::endl; std::cout <<"std::string = "<<s<<std::endl; } 带有注释行的输出是: std::string = Hello std::wstring = Hello std::string = Hello 但不只是: std::wstring = Hello 示例中有什么问题吗?我可以进行上述转换吗? 编辑 新的示例(考虑了一些答案)是 #include <string> #include …