Click here to Skip to main content
15,910,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLPTSTR, LPCTSTR, CString and others... Pin
Kaleb Pederson15-Jul-04 9:22
Kaleb Pederson15-Jul-04 9:22 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Toni7815-Jul-04 9:40
Toni7815-Jul-04 9:40 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Adam Durity15-Jul-04 9:49
Adam Durity15-Jul-04 9:49 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Antti Keskinen15-Jul-04 9:53
Antti Keskinen15-Jul-04 9:53 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Kaleb Pederson15-Jul-04 11:25
Kaleb Pederson15-Jul-04 11:25 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Antti Keskinen15-Jul-04 11:50
Antti Keskinen15-Jul-04 11:50 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
PJ Arends15-Jul-04 17:14
professionalPJ Arends15-Jul-04 17:14 
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
Mike Dimmick15-Jul-04 9:58
Mike Dimmick15-Jul-04 9:58 
Couple of links:

The complete guide to C++ strings, part I[^]
The complete guide to C++ strings, part II[^]

Basically, LPxSTR is a typedef for xCHAR*, i.e. LPTSTR is a typedef for TCHAR*, LPSTR for CHAR*, and LPWSTR for WCHAR*. If it has a C in it, it's a const: LPCSTR is const CHAR*.

So what are CHAR, WCHAR and TCHAR? CHAR is simply a typedef for char. Don't know why they did that. WCHAR is a typedef for wchar_t which on earlier compilers is a typedef for unsigned short.

TCHAR is where it gets interesting. The meaning of TCHAR depends on whether UNICODE is defined or not. If UNICODE is not defined, TCHAR is CHAR. If UNICODE is defined, TCHAR is WCHAR. With the addition of suitable macros (such as the _T you use) a program can be mostly adapted between ANSI and UNICODE builds with few source code changes.

Anyway, after all that, LPTSTR is equivalent to WCHAR* in UNICODE builds and char* in ANSI builds. Use whatever memory allocation seems appropriate.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: LPTSTR, LPCTSTR, CString and others... Pin
digwizfox15-Jul-04 11:07
digwizfox15-Jul-04 11:07 
Generalabt running exe Pin
jass198115-Jul-04 9:20
sussjass198115-Jul-04 9:20 
GeneralRe: abt running exe Pin
Toni7815-Jul-04 9:42
Toni7815-Jul-04 9:42 
GeneralRe: abt running exe Pin
PJ Arends15-Jul-04 9:47
professionalPJ Arends15-Jul-04 9:47 
GeneralRe: abt running exe Pin
Paul Steane16-Jul-04 1:33
Paul Steane16-Jul-04 1:33 
GeneralIJolietDiscMaster & Joliet & Invalid Naming Convention Pin
epxhi15-Jul-04 9:10
epxhi15-Jul-04 9:10 
GeneralDumb loop question. Pin
RobJones15-Jul-04 9:03
RobJones15-Jul-04 9:03 
GeneralRe: Dumb loop question. Pin
palbano15-Jul-04 9:19
palbano15-Jul-04 9:19 
GeneralRe: Dumb loop question. Pin
RobJones15-Jul-04 9:24
RobJones15-Jul-04 9:24 
GeneralRe: Dumb loop question. Pin
palbano15-Jul-04 9:30
palbano15-Jul-04 9:30 
GeneralRe: Dumb loop question. Pin
RobJones15-Jul-04 9:50
RobJones15-Jul-04 9:50 
GeneralRe: Dumb loop question. Pin
palbano15-Jul-04 17:54
palbano15-Jul-04 17:54 
Generaltypedef Pin
Adam Durity15-Jul-04 8:31
Adam Durity15-Jul-04 8:31 
GeneralRe: typedef Pin
Maximilien15-Jul-04 8:35
Maximilien15-Jul-04 8:35 
GeneralASCII strings from file Pin
Oriocat15-Jul-04 8:24
Oriocat15-Jul-04 8:24 
GeneralRe: ASCII strings from file Pin
Antti Keskinen15-Jul-04 9:28
Antti Keskinen15-Jul-04 9:28 
GeneralUser WM messages Pin
0v3rloader15-Jul-04 7:07
0v3rloader15-Jul-04 7:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.