且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将wchar_t *转换为字符串

更新时间:2023-11-05 09:37:04

使用wstring,请参见以下代码:

Use wstring, see this code:

// Your wchar_t*
wchar_t* txt = L"Hello World";
wstring ws(txt);
// your new String
string str(ws.begin(), ws.end());
// Show String
cout << str << endl;