i'm trying to output a tree to a file. here's what i was trying:
Code:
save(treenode *treeroot, ofstream outfile){
if(!treeroot) return;
save(treeroot->left,outfile);
oufile<<treeroot->data;
save(treeroot->right,outfile);
}
int main(){
treenode *treeroot;
//do stuff
ofstream outfile("file.txt",ios::out);
save(treeroot, outfile);
}
the error i got was ios is private, or something like that.
how can i get this to work, or is there a better way to do this?
another thing i was wondering, is there a way to output to a file without deleteing the data already in the file?
for example: if i had a file file.txt with the data from the tree in it, and then i ran the program and added stuff to the tree, can i open file.txt and add only the new element of the tree, or do i have to outfile the whole tree again?
thanks.