Lecture 11

That is fast and fast is good make space thats

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: st do it. That is fast! (And fast is good). Make Space + --- --+ That’s why we need to study both.... 13 14 HOW TO SAVE A LINKED LIST TO A FILE Pointers are machine addresses. If you run the same program 10 times they can be different every time. It makes no sense to save pointers. What you have to do is write the data fields only and then recreate the linked list by calling insert repeatedly. void SaveLinkedList(char *fname) { ofstream F(fname, ios::binary); for (cur = head; cur != NULL; cur = cur F << cur data << endl; F.close( ); } 15 To recreate the linked list, there are...
View Full Document

Ask a homework question - tutors are online