C++ - How do you convert from String to TCHAR*? -
here's code:
string str = "hello!"; tchar* tch = new tchar[str.length() + 1]; mbstowcs_s(null, tch, _tcslen(tch), str.c_str(), str.length()); // use tch other stuff... delete [] tch; // gives debug heap corruption assertion
for reason i'm getting heap corruption assertion code. i'm racking brain trying figure wrong. can't find documentation similarities , differences between strings , tchars me figure out on own.
_tcslen(tch)
gives wrong result since tch
not initialized @ point. assume should pass str.length() + 1
(the size of buffer) there.
Comments
Post a Comment