Pointer Question

Please discuss general Delphi programming topics here.

Pointer Question

Postby sepehr » December 18th, 2007, 1:59 pm

i have the following code:

Code: Select all
var
S:String;
P:^string;
begin
P:=@s;
showmessage(P^);
end;


the content of P is shown and i know P is pointing to S,but exactly where? the very first memory unit of S? S[0]?

and another thing
in C we have *(a+1) which means defrencing the next memory unit after a, do we have such thing in delphi?
User avatar
sepehr
Active Member
Active Member
 
Posts: 23
Joined: October 4th, 2006, 6:38 am
Location: Karaj

Postby Johnny_Bit » December 19th, 2007, 5:13 pm

P points to beginning of S, exactly the first MemCell of S.

As to second question: pointer magic in C is normal thing, in delphi it's pain in a**. To get something to work i had to do something like typecasting pointer to dword, doing math then back to pointer.
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron