As a matter of fact, I create a list, fill it with some numbers, and then I want to remove the element with the key = 6
, but it does not work, even after dispose(b)
it manages me to display the result 6 without problems, how is it? The brain cannot enter, but I deleted the cell with the number b from the memory, well, or something like that
type stack = ^st; st = record data:Integer; next:stack; end; var i,k:Integer; b,a,c:stack; begin new(b); b^.data:=0; a:=b; for i := 1 to 9 do begin new(b^.next); b:=b^.next; b^.data:=i; end; k:=6; c:=a; while c<>nil do begin if c^.data = k then begin b:=c; c:=c^.next; break; end; c:=c^.next; end; dispose(b); WriteLn(b^.data); { while a<>nil do begin WriteLn(a^.data); a:=a^.next; end; } ReadLn; end.