0

I can see that i can cast a string type to LPCWSTR in a parameter like this:

myfunc(L"mystring");

But suppose i want to pass a string as a variable this time, how would i cast it with ease like above (not converting the variable):

string myStringVar = "mystring";
myfunc(myStringVar);

I tried a few things like:

myfunc(L{mystringvar});
jimmy
  • 73
  • 1
  • 7

1 Answers1

1

If you want to use a wide string you need a std::wstring. You could use it like

std::wstring myStringVar = L"mystring";
myfunc(myStringVar.c_str());
NathanOliver
  • 171,901
  • 28
  • 288
  • 402