我有以下代码。
wchar_t path[MAX_PATH +1] = {0};
SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
这里我将程序数据文件夹路径设为“路径”,即wchar_t。我想将它转换为 wstirng 并打印出来。我该怎么做?
最佳答案
尝试以下操作
#include <string>
#include <iostream>
int main() {
wchar_t path[MAX_PATH +1] = ...;
std::wstring s(path);
std::wcout << s;
return 0;
}
关于c++ - 在 C++ 中将 wchar_t 转换为 wstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22833252/