I need to create a linked list where I can continue to input integers and I'm not sure what I'm doing wrong, but every time I run it I'm allowed to enter two numbers and then I get exit code 216 saying I'm accessing memory I'm not allowed to.
Program List;
uses
crt;
type
RecMemLoc= ^Rec;
Rec=Record
Data:integer;
Next: RecMemLoc;
end;
var
MemLoc: ^integer;
Num: RecMemLoc;
New: RecMemLoc;
Procedure Input(var Num, New: RecMemLoc);
var
choice:char;
Begin
New(Num);
Writeln('Input Num');
Readln(Num^.Data);
Repeat
Begin
clrscr;
Writeln('Do you want to enter another number?');
readln(Choice);
New(New);
New:=Num;
New:=New^.Next;
Writeln('Input Number');
Readln(New^.Data);
End;
Until(Choice='N');
New:=New^.Next;
New:=Nil;
End;
Procedure Output(var Num, New: RecMemLoc);
Begin
write(Num^.Data);
Repeat
Begin
New:=Num;
New:=New^.Next;
write(New^.Data);
end;
Until(New=Nil);
End;
Begin
clrscr;
input(Num, New);
output(Num, New);
readln;
End.