Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


LPSTR variable type

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Jun 25, 2008 10:06 am    Post subject: LPSTR variable type Reply with quote

Ok. LPSTR is an "alias for PSTR" (quoted MSDN). Basically, a pointer to a string, or char*. If it is already a pointer how come you cannot do this:

Code:

LPSTR bla = new LPSTR;


You have to do:

Code:

LPSTR *bla = new LPSTR;


But LPSTR as stated is a char*. If you do this:

Code:

char *bla = new char;


That works. Why doesn't LPSTR work just by doing this:

Code:

LPSTR bla = new LPSTR

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed Jun 25, 2008 11:01 am    Post subject: Re: LPSTR variable type Reply with quote

oib111 wrote:
Ok. LPSTR is an "alias for PSTR" (quoted MSDN). Basically, a pointer to a string, or char*. If it is already a pointer how come you cannot do this:

Code:

LPSTR bla = new LPSTR;


You have to do:

Code:

LPSTR *bla = new LPSTR;


But LPSTR as stated is a char*. If you do this:

Code:

char *bla = new char;


That works. Why doesn't LPSTR work just by doing this:

Code:

LPSTR bla = new LPSTR


Ok looking at the bottom 2 exambles. char *bla = new char works while LPSTR bla = new LPSTR.

In the first one you are taking a pointer to bla and making it a non pointer char. In the second one you are taking a pointer to a new pointer. See the difference.

So to test this theory on LPSTR go try to compile this

char *bla = new char*;

Also LPSTR != PSTR.

Long Pointer String
Pointer String

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Jun 25, 2008 11:10 am    Post subject: Reply with quote

http://msdn.microsoft.com/en-us/library/cc230353.aspx wrote:

The LPSTR type and its alias PSTR specify a pointer to an array of 8-bit characters, which MAY be terminated by a null character.


also...

http://winprog.org/tutorial/start.html wrote:

An LP prefix stands for Long Pointer. In Win32 the Long part is obsolete so don't worry about it.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Wed Jun 25, 2008 11:32 am    Post subject: Reply with quote

Code:
typedef __nullterminated CHAR *NPSTR, *LPSTR, *PSTR;


All the same.
With other types like BYTE:

Code:
typedef BYTE near           *PBYTE;
typedef BYTE far            *LPBYTE;


Thing is, near and far Have no actual definition, just a word.

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites