Hiya!
I've been making a binary tree over the last couple of days, and i've got stuck on saving it! I need to save it and then read it back into memory when i load the program up.
Obviously doing a pre-order traversal, but it wont work, when using recursion and I/O do you have to change things?
I've got a feeling i'm missing something really simple! I had a search and coulddnt find anyone with a similar propblem.
Cheers for any advice!
snipet of my code:
void saveIndexINT()
{
saveIndex(root);
}
void saveIndex(node *currentNode)
{
ofstream indexOut;
indexOut.open("indexData.txt", ios:: out); <-----emoticons!!! ignore the space
if(currentNode != NULL)
{
indexOut << currentNode->name << "*" << currentNode->recNo << endl;
saveIndex(currentNode->left);
saveIndex(currentNode->right);
}
indexOut.close();
}



LinkBack URL
About LinkBacks



ut);