Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以看到我可以在这样的参数中将字符串类型转换为 LPCWSTR:
myfunc(L"mystring");
但是假设这次我想将一个字符串作为变量传递,我将如何像上面那样轻松地转换它(不转换变量):
string myStringVar = "mystring"; myfunc(myStringVar);
我尝试了一些方法,例如:
myfunc(L{mystringvar});
如果你想使用一个宽字符串,你需要一个std::wstring. 你可以像这样使用它
std::wstring
std::wstring myStringVar = L"mystring"; myfunc(myStringVar.c_str());