I have a string (std::wstring variable) with different paths. I am converting that string to WCHAR so that i can tokenize the string and also i can resolve the path (starting with % symbol) using ExpandEnvironmentStrings.
When doing that I am getting the below error: Error C2665 'wcstok': none of the 2 overloads could convert all the argument types.
It is because we are passing const WCHAR* variable in wcstok.
Could anyone please help me how to use const WCHAR* variable in wcstok? Below is the code snippet for that:
std::wstring wstrFileLocation;
std::vector<std::wstring> pathsVector;
const WCHAR * wpszProcToSearch = wstrFileLocation.c_str();
TCHAR szOut[MAX_PATH];
const wchar_t delim[] = L".xml";
wchar_t* ptr;
wchar_t *token = wcstok(wpszProcToSearch, delim, &ptr);
while (token != NULL)
{
ExpandEnvironmentStrings(token, szOut, ARRAYSIZE(szOut));
pathsVector.push_back(szOut);
}
Aucun commentaire:
Enregistrer un commentaire