This preview shows page 1. Sign up to view the full content.
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;
} 15 To recreate the linked list, there are...
View Full Document