If you do not want to modify the string, then try one of solutions:
CString s( _T( "ala bala portocala" ) );
CStringA s2( s );
const char* c = s2;
C becomes invalid when s2 is destroyed.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a SDI unicode project. I was tried:
CString s(_T("ala bala portocala"));
char* c = (char*)(LPCTSTR)s;
but in c I have 'a' only. When I tried:
CString s(_T("ala bala portocala"));
char* c = s.GetBuffer(s.GetLength());
s.ReleaseBuffer();
I got:
error C2440: 'initializing' : cannot convert from 'wchar_t *' to 'char *'
How to do the right conversion ?
If you do not want to modify the string, then try one of solutions:
CString s( _T( "ala bala portocala" ) );
CStringA s2( s );
const char* c = s2;
C becomes invalid when s2 is destroyed.