Hi, I'm trying to update a file with an information in a binary tree. However my algorithm is working only for one NODE.
Any suggestion will be appreciated!
void Arbol::updateFile()
{
Nodeptr p = miArbol; // myTree
Recorrer(p);
cout << "File updated!" << endl;
cout << endl;
}
void Arbol::Recorrer(Nodeptr p)
{ // Recorrer began
if (p != NULL)
{ // if began
Recorrer(p->left);
fstream fout;
fout.open("data.txt", ios::out);
if ( !fout.fail() )
{ // if began
fout << p->Objperson.nombre << endl;
fout << p->Objperson.ss << endl;
fout << p->Objperson.edad << endl;
} // if end
else
{ // else began
cerr << "File can't be open!" << endl;
exit(1);
system("PAUSE");
} // else end
fout.close();
Recorrer(p->right);
} // if end
} // Recorrer end