c++ - Converting between WCHAR* to wstring without use of constructor -


I have a wchar array that requires me to write data to use a WinAPi function, Code> std :: wstring , I know std :: wstring t (wText); works, but I can not declare it in an if statement because it does not exist outside of it's scope. Apart from this, I can not call Constructor in this fashion:

  WCHAR wText [256]; Std :: wstring t = "L"; If (some condition) {T = T (wText); }  

What can I do? I should be equal to wstring "" When the situation is not complete and when it is complete I want to get a WCHAR array in it.

You can create a temporary std :: wstring object, Such as by calling Constructor in Expression:

  t = std :: wstring (wText);  

Comments