I am reading in a file directory from the user through the console, and I must store the value in a pxcCHAR*
variable, which is the SDK's typedef
for wchar_t*
.
I found that I can do the conversion from std::string
to std::wstring
by doing the following.
#include <iostream>
int main(){
std::string stringPath;
std::getline(std::cin, stringPath);
std::wstring wstrPath = std::wstring(stringPath.begin(), stringPath.end());
const wchar_t* wcharPath = wstrPath.c_str();
return 0;
}
When I run this code, I see these values through debugging.
stringPath= "C:/Users/"
wstrPath= L"C:/Users/"
wcharPath= 0x00b20038 L"C:/Users/"
Where is the value concatenated to the front of wcharPath
coming from?
Furthermore,
Because pxcCHAR*
is a typedef
for wchar_t*
, I thought it would be okay to simply do this:
pxcCHAR* mFilePath = wcharPath;
However, I get a message saying that "const wchar_t*" cannot be used to initialize an entity of type "pxcCHAR*".
I expected implicit conversion to work, but it doesn't. How can I overcome this error?