Write an Pascal - Pointer to Pointer Initialization - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, September 23, 2017

Write an Pascal - Pointer to Pointer Initialization

Pointer to Pointer Dynamic Initialization 

Program:
program exPointertoPointers;
type
iptr = ^integer;
pointerptr = ^ iptr;

var
num: integer;
ptr: iptr;
pptr: pointerptr;
x, y : ^word;

begin
num := 3000;

(* take the address of var *)
ptr := @num;

(* take the address of ptr using address of operator @ *)
pptr := @ptr;

(* let us see the value and the adresses *)
x:= addr(ptr);
y := addr(pptr);

writeln('Value of num = ', num );
writeln('Value available at ptr^ = ', ptr^ );
writeln('Value available at pptr^^ = ', pptr^^);
writeln('Address at ptr = ', x^);
writeln('Address at pptr = ', y^);
end.


Output:
Value of num = 3000
Value available at ptr^ = 3000
Value available at pptr^^ = 3000
Address at ptr = 36864
Address at pptr = 36880

No comments:

Post a Comment