program Ptint;
(* File : Ptint.pas *)
(* Pointer ke integer *)
(* Kamus *)
var
(* File : Ptint.pas *)
(* Pointer ke integer *)
(* Kamus *)
var
i : integer;
Pti : ^integer ;
Pti : ^integer ;
Begin (* Algoritma *)
i := 5;
new (Pti); (* alokasi *)
Pti^ := 10;
writeln ('i = : ', i );
writeln ( 'Nilai yang ditunjuk Pti = ', Pti^ );
dispose (Pti); (* dealokasi *)
new (Pti); (* alokasi *)
Pti^ := 10;
writeln ('i = : ', i );
writeln ( 'Nilai yang ditunjuk Pti = ', Pti^ );
dispose (Pti); (* dealokasi *)
end.
=============================================================
program PTab;
(* File : PTab.pas *)
(* Pointer ke tabel integer *)
(* Kamus *)
type TabInt = array [1..10] of integer;
var
=============================================================
program PTab;
(* File : PTab.pas *)
(* Pointer ke tabel integer *)
(* Kamus *)
type TabInt = array [1..10] of integer;
var
T : TabInt;
i : Integer;
pt: ^TabInt;
i : Integer;
pt: ^TabInt;
begin (* Algoritma *)
for i := 1 to 10 do
begin
begin
T [i] :=i;
end;
(* alokasi Pointer ke tabel integer *)
new (pt) ; (* alokasi *)
Pt^ := T; (* pendefinisian isi/nilai yang ditunjuk *)
(* akses elemen *)
for i := 1 to 10 do
begin
(* alokasi Pointer ke tabel integer *)
new (pt) ; (* alokasi *)
Pt^ := T; (* pendefinisian isi/nilai yang ditunjuk *)
(* akses elemen *)
for i := 1 to 10 do
begin
writeln ( 'i= ', i, ' pt&[i] = ', pt^[i] );
end;
dispose (pt);
dispose (pt);
end.
==============================================================
program PRec;
(* File : PRec.pas *)
(* Pointer ke record *)
(* Kamus *)
type
==============================================================
program PRec;
(* File : PRec.pas *)
(* Pointer ke record *)
(* Kamus *)
type
Point = record
x: integer;
y: integer;
y: integer;
end;
var
T : Point ;
Pt : ^Point;
Pt : ^Point;
begin (* Algoritma *)
new (Pt); (* alokasi *)
Pt^.x := 10; Pt^.y := 5; (* akses komponen titik *)
with Pt^ do
begin (* dengan WITH *)
Pt^.x := 10; Pt^.y := 5; (* akses komponen titik *)
with Pt^ do
begin (* dengan WITH *)
writeln ( 'Absis P : ', x);
writeln ( 'Ordinat P : ', y);
writeln ( 'Ordinat P : ', y);
end; (* kenapa tidak dilakakan dispose ? *)
end.