From: gt7693d@acmex.gatech.edu (Daniel J)
Subject: Simple Pointer Problem, Help...
Date: 1996/05/24
Date: 1996-05-24T00:00:00+00:00 [thread overview]
Message-ID: <4o2vu9$hdc@catapult.gatech.edu> (raw)
To any friendly programmer,
Take a look at this code and read the comments at end, they seem
self explanatory.
--Types and declarations
type NumRecord;
type NumPtr is access NumRecord;
type NumRecord is
record
Value : Integer;
Next : NumPtr;
end record;
Num : NumPtr;
--Modules
--Purpose: Add a node to the end of a linked list
procedure AddNodeBack (Point : in out NumPtr;
Value : in Integer) is
begin
if Point /= null then
while Point /= null loop
Point := Point.Next;
end loop;
Point := new NumRecord'(Value, null);
else
Point := new NumRecord'(Value, null);
end if;
end AddNodeBack;
--Body
Num := new NumRecord'(0, null);
for I in 1..10 loop
AddNodeBack (Num, I);
end loop;
The output of the body gives me one node, which is not what I want.
I desire a linked list of N nodes w/values in ascending order, according to
my body.
What am I doing wrong, for I've run outta ideas?
ps I've tried to use a temp pointer within AddNodeBack, but got the same
output.
_____________________________________________________________________________
Daniel J. Feren |
327693 GA Tech Station | GTRI/ELSYS/SEN
Atlanta, Georgia 30332 | Co-Op Win/Sum
__________________________________|__________________________________________
Email: gt7693d@prism.gatech.edu
Homepage: http://www.prism.gatech.edu/~gt7693d
next reply other threads:[~1996-05-24 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-24 0:00 Daniel J [this message]
1996-05-24 0:00 ` Simple Pointer Problem, Help Peter Hermann
1996-05-24 0:00 ` John Herro
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox