Can someone explain to me how to save a linked list onto a disk file. When I try the usual 'write' statements, I get error messages. I have searched my text and the web, but can come up with nothing.
I have created a program that allows users to enter information which is then put into a linked list. The problem is that I can't get it to write the info to the disk, so whenever I start the program again, the file is read as gibberish.
Please help.
Laura
Comments
to write out the linking information, simply write out the records in the
order that the list determines. When reading back in simply add the
records to the list one at a time until you get to the end of the file.
Supposing your list was on the heap then the data types might be:
yourdatatype = record ......{as required}
heaptype = record
data : yourdatatype ;
prev,next : pointer ;
end ;
The file is then simply one of yourdatatype and should work with the normal
read and write statements.