home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_03
/
1n03008b
< prev
next >
Wrap
Text File
|
1990-06-14
|
536b
|
40 lines
----------
Listing 2
var
p1, p2, p3, p4 : ^longint;
begin
{*
* Grab three chunks from the heap.
*}
new(p1);
p1^ := 1;
new(p2);
p2^ := 2;
new(p3);
p3^ := 3;
{*
* Return the second chunk to the heap and grab
* another.
*}
dispose(p2);
new(p4);
p4^ := 4;
{*
* Whoops! I forgot that I disposed of the second
* chunk.
*}
p2^ := -2;
{*
* Now look at the results...
*}
writeln('p1^ = ', p1^);
writeln('p2^ = ', p2^);
writeln('p3^ = ', p3^);
writeln('p4^ = ', p4^);
end.
----------