Karim
02-12-2005, 02:03 AM
I'm ouputting the contents of a linked list to a file. It works when there is no existing file. However, when a file already exists with valid content, I can import the data to a linked list, I can modify and display the contents which correctly amends the list but it won't write the modified list to file.
void write_list(ofstream &data, To_Do_Item_Ptr head)
{
To_Do_Item_Ptr temp = head;
while (head != NULL)
{
data << head -> desc << endl;
temp = temp -> next;
if (temp != NULL && (head -> priority > temp -> priority))
{
data << endl;
}
head = head -> next;
}
data.close();
}
Tracing through the while loop, it iterates the correct number of times so it looks like the data is being written to file but no such luck...
void write_list(ofstream &data, To_Do_Item_Ptr head)
{
To_Do_Item_Ptr temp = head;
while (head != NULL)
{
data << head -> desc << endl;
temp = temp -> next;
if (temp != NULL && (head -> priority > temp -> priority))
{
data << endl;
}
head = head -> next;
}
data.close();
}
Tracing through the while loop, it iterates the correct number of times so it looks like the data is being written to file but no such luck...