> Hi all,
> I am stuck in my program, which is supposed to simulate a basic flight
> booking system, at the point where I have to use an array of pointers.
I
> have never used the pointers as arrays and I am really confused.
> I am pasting some of the code, can please anybody give me a clue on
what to
> change to get the procedure to work.
> I am still at the beginning of the program, I will have to add,
delete,
> modify, etc, manipulate this array of linked list in all possible
ways, but
> if somebody could help me on this first procedure, adding of a
passenger in
> a flight, I will know to do the rest, because I know to work with
simple
> linked lists. All I need is to get the idea of an array of linked
> lists...Thanks in advance for any help.
> Program Flight;
> Type
> flights = (CY357, BA234, MA246);
> listpointer = ^ listnode;
> listnode = record
> name : packed array[1..10] of char;
> seat : integer;
> link: listpointer;
> end;
> pointerarray = array[flights] of listpointer;
> Var
> choice : char;
> arraypointers : pointerarray;
> Procedure Selectflight(var flightno: flights);
> Var
> fl : integer;
> valid : boolean;
> Begin
> writeln('Select one of the available flights with the options: ');
> writeln('1 for CY357');
> writeln('2 for BA234');
> writeLn('3 for MA246');
> writeln('0 for exit');
> valid := false;
> repeat
> readln(fl);
> if fl = 1 then flightno := CY357 else
> if fl = 2 then flightno := BA234 else
> if fl = 3 then flightno := MA246 else
> if fl = 0 then valid := true else
> if fl > 3 then
> begin
> writeln('Please try again');
> valid := true;
> end;
> until valid;
> End;
> ----------- here is the code that I am confused about --------------
> Procedure Addpassenger(var oneflight: flights; var l: arraypointers);
> var p: arraypointers;
> begin
> Selectflight(oneflight);
> new(oneflight[l]); <-------