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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -