lundi 25 juillet 2016

C++ Convert string to TCHAR*

Below is my code :

string szDllPath = "12345";
size_t size = szDllPath.length();
TCHAR* wArr = new TCHAR[size];
for (size_t i = 0; i < size; ++i)
    wArr[i] = _T(szDllPath[i]);

cout<<szDllPath<<endl;
cout<<wArr<<endl;

And I get this :

enter image description here

I don't understand why I get the extra characters, and how to solve it ?

Aucun commentaire:

Enregistrer un commentaire