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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to