Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LPSTR and CHAR* ??

Status
Not open for further replies.

Sen7inel

IS-IT--Management
Feb 14, 2001
90
FI
I'm getting familiar with Windows programming. However, I'm pretty confused with some of these data types. What exactly is the difference between LPSTR, which supposedly points to mem address where a null-terminated string begins, and CHAR* which also is a pointer to a null-terminated string?
 
this is quite no difference. LPSTR is made for code portability only.

Ion Filipski
1c.bmp
 
There used to be.

LPSTR was defined as "char FAR*" back in the days when that mattered (i.e. 16 bit) and pointers defaulted to near.
 
For portability between MBCS, Unicode and normal character sets, use LPTSTR and LPCTSTR instead of LPSTR and LPCSTR.
 
>>That is correct, both data types are the same and serve the same purpose.

Nope, they're not the same. They can be the same. Whether a LPSTR is a CHAR or a WCHAR pointer depends on compiler options set (non-unicode or unicode builds).

Greetings,
Rick
 
>LazyMe
You're kidding.
LPSTR is never WCHAR, any options you give to compiler. Don't confuse with LPTSTR.

Ion Filipski
1c.bmp
 
Whoops!!??

No, not kidding (this time); just misreading.... tired I guess

Greetings,
Rick
 
LPTSTR can be either CHAR or WCHAR depending on compilation flags (MBCS, Unicode). Use TCHAR to be safe.
 
Thanks for replies.

And I used LPSTR and CHAR instead of LPTSTR and TCHAR just so that we'd avoid the whole unicode issue, which I already was familiar with. =D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top