Convert lptstr to char*


Question

Would anyone happen to know how to convert type LPTSTR to char * in C++?

1
15
4/24/2013 12:04:05 PM

Accepted Answer

Depends if it is Unicode or not it appears. LPTSTR is char* if not Unicode, or w_char* if so.

Discussed better here (accepted answer worth reading)

11
12/5/2008 3:03:08 AM

Here are a lot of ways to do this. MFC or ATL's CString, ATL macros, or Win32 API.

LPTSTR szString = _T("Testing");
char* pBuffer;

You can use ATL macros to convert:

USES_CONVERSION;
pBuffer = T2A(szString);

CString:

CStringA cstrText(szString);

or the Win32 API WideCharToMultiByte if UNICODE is defined.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon