Hi again, this is a simple programme that I can't make work :S in turbo pascal.
Write a program to create a new list and then display it through a Recursive Procedure ( and use 'p' as a local variable).
This is what I could do but considering I hate procedures and functions it gives me the 'OverFlow' error.
I think the procedure of creation is ok but the recursive one must be chaged.
Any help?
[B]Program[/B] List56;
[B]Uses[/B] CRT;
[B]Type[/B]
student=^pointer;
pointer=[B]record[/B]
name:string[10];
next:student;
[B]end;[/B]
Var org, p1 :student;
[B]Procedure[/B] Cr8List;
[B]Begin[/B]
[B]new[/B](p1);
org:=nil;
p1:=org;
[B]Writeln[/B]('Type the names of the students,( hit enter to stop).');
[B]Writeln;[/B]
[B]writeln;[/B]
[B]Write[/B]('Name: ');
[B]readln([/B]p1^.name);
[B]While[/B] p1^.name <> '' [B]do[/B]
[B]Begin[/B]
p1^.next:=org;
org:=p1;
[B]Write[/B]('Name: ');
[B]new[/B](p1);
[B]readln[/B](p1^.name);
[B]end;
end;[/B]
Procedure RecursiveDisplay(p:student);
[B]begin[/B]
[B]while [/B]p<> [B]nil do[/B]
[B]begin[/B]
[B]Writeln[/B]('Name: ',p^.name);
p:=p^.next;
AfishimRekursiv(p);
dispose(p);
[B]end;
end;[/B]
[B]Begin[/B]
CLRSCR;
Cr8List;
p1:=org;
RecursiveDisplay(p1);
[B]end.[/B]