| 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?
|
Posted: Wed Jun 25, 2008 10:06 am Post subject: LPSTR variable type |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Jun 25, 2008 11:01 am Post subject: Re: LPSTR variable type |
|
|
| 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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Jun 25, 2008 11:10 am Post subject: |
|
|
| 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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed Jun 25, 2008 11:32 am Post subject: |
|
|
| 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 |
|
 |
|