Hi i'm trying to convert LPWSTR but always i dont know but i complicate my life when i have a data like this. I know that LPWSTR is a long pointer to a constant string. I must to convert in this code to string the code is the follow:
1 2 3
LPWSTR pi = L"PAPUCHI";
std::string MyString = CW2A (pi);
LPSTR vi = MyString.c_str();
//Warning: This function loses data!
std::string to_string(LPWSTR *ws){
std::string ret;
ret.reserve(wcslen(ws));
for (;*ws; ws++)
ret += (char)*ws;
return ret;
}
Note that instead of this:
1 2 3
LPWSTR pi = L"PAPUCHI";
std::string MyString = to_string(pi);
LPSTR vi = MyString.c_str();