{ When you call new(p), you are asking the operating system to give you a chunk of memory for your use. When you are done using that memory, you should give it back to the operating system. This giving back process is called "disposing" of the memory. To dispose of a node pointed to by a pointer p, you do this: dispose( p ); Write a procedure DeleteString as described below. (Note that it's hard to be sure you've got this right, since dispose doesn't tell you anything.) } program copying(input,output); type nodePtr = ^node; node = record data : char; next : nodePtr end; var message : nodePtr; { ReadString reads characters from the keyboard until reaching the end of a line. The characters are put into a linked list, with str pointing to the head of the list (which is also the first character read). } procedure ReadString( var str : nodePtr ); var currentNode : nodePtr; begin if eoln then str := nil else begin new( currentNode ); read( currentNode^.data ); str := currentNode; while not eoln do begin new( currentNode^.next ); currentNode := currentNode^.next; read( currentNode^.data ) end; currentNode^.next := nil end end; { WriteString prints a string stored as a linked list of characters. } procedure WriteString( str : nodePtr ); var currentNode : nodePtr; begin currentNode := str; while currentNode <> nil do begin write( currentNode^.data ); currentNode := currentNode^.next end end; {Dispose of the nodes in the linked list pointed to by str.} procedure DeleteString( str : nodePtr ); begin end; begin write( 'Type something: ' ); ReadString( message ); write( 'You typed: ' ); WriteString( message ); writeln; DeleteString( message ) end.