Ok im printing a tree in ascending order, on the monitor it does it quite well. But what i wanted to do was to print the same thing that pops on screen to a text file, it does print it but not in order. For instance if i enter, "jake,bert,zena" on screen its ok like "bert,jake,zena", but when written to a file it comes out as "bert,zena,jake"
Can anyone point out my crappy logic, or help me out in fixing it? Thanks! There is the code:
Code:
void printtree_asc(BST t)
{
FILE *dataOutput;
dataOutput = fopen("fileOutput.txt","a+");
if (dataOutput == NULL) {
printf("OooooPppppsss Out of Memory!");
sleep(3);
exit (-1);
}
if (t!=NULL) {
printtree_asc(t->left);
printf("\n %d \t %s",t->info,t->fname);
fputs(t->fname,dataOutput);
fputs("\n",dataOutput);
printtree_asc(t->right);
}
fclose(dataOutput);
}

