Page 1 of 1

Pointer Question

PostPosted: December 18th, 2007, 1:59 pm
by sepehr
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?

PostPosted: December 19th, 2007, 5:13 pm
by Johnny_Bit
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.