[fpc-pascal] Pointer
Luis Del Aguila
luis3000 at ec-red.com
Tue Nov 15 17:11:32 CET 2005
Somebody can help me.
I do not understand, that I am making bad.
The program is:
Program ProbandoMemoria;
{$R+}
Var
PLPunteros: ^Pointer;
NuevoTamanio : integer;
elementos : longint;
x,b : ^integer;
Begin
elementos := 3;
NuevoTamanio:=Sizeof(Pointer)*elementos;
ReallocMem(PlPunteros,NuevoTamanio);
Writeln('Direccion : ',longint(Plpunteros) );
new(x);
x^:=7;
Plpunteros^:=x;
b:=Plpunteros^;
Writeln('Direccion : ',longint(b),' valor : ',b^);
new(x);
x^:=15;
(Plpunteros+4)^:=x;
b:=(Plpunteros+4)^;
Writeln('Direccion : ',longint(b),' valor : ',b^);
new(x);
x^:=25;
(Plpunteros+8)^:=x;
b:=(Plpunteros+8)^;
Writeln('Direccion : ',longint(b),' valor : ',b^);
//This I do not understand.
//Why ' b^ ' does not have the 7?
b:=nil;
b:=PlPunteros^;
Writeln('Direccion : ',longint(b),' valor : ',b^);
Readln;
End.
The result is:
Direccion : 604444
Direccion : 604460 valor : 7
Direccion : 604476 valor : 15
Direccion : 604492 valor : 25
Direccion : 604460 valor : 604476
Thanks.
Att.
Luis Del Aguila
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20051115/7c4cf867/attachment.html>
More information about the fpc-pascal
mailing list