See the following code segment.
CString myCString = _T("Hello"); const TCHAR* myCharString = LPCTSTR(myCString);
Some Background Info
- TCHAR will be evaluated to char if _UNICODE is not defined. Otherwise it will be evaluated to wchar.
- LPCTSTR is also a data type which is nothing but const char* or const wchar*, depending on whether _UNICODE defined or not.
- CString has a constructor which accepts TCHAR*.
- The macro _T will make the supplied string neutral. That is, if _UNICODE is defined, the string will be in 16 bit unicode format, otherwise in 8 bit ANSI format.