Original Post
Hello all, I am trying to write a program that needs to save information from a Tree. naturally, I''m sure most have come across this before.
I have a Binary Tree, with each node being information about a User.
so far, in the class I have:
----------------CODE---------
class BTreeNode{
public:
BTreeNode *pLow;
BTreeNode *pHigh;
char *Name;
__fastcall BTreeNode();
};
class BTUser: public BTreeNode{
public:
char *Password;
};
-----------------------------
so I have a Name, a Password, and pointers that are used to navigate the tree.
really the pointers have no relevance i don''t think here, as it is the class that I wish to save.
So far I am trying to save just the first node, to see if I can get it to work. Basically it isn''t, and it is MOST bizzare. I save it to a file like this...
---------------------CODE---------
FILE *savef = fopen(FileName.c_str(),"w+");
BTUser *save = (BTUser*)dlMain->Users->Head;
BTUser temp;
temp.pLow = temp.pHigh = NULL;
strcpy(temp.Name,save->Name);
fwrite(&temp,sizeof(BTUser),1,savef);
fclose(savef);
---------------------------------
ok... so that seems to work, then I load it, and it mucks up the name and the password!! I load it like this...
------------CODE----------------
--------------------------------
this code works however when I set the values of Password & Name like this...
Name = "hello";
Password = "gbye";
Any tips that you have are all welcome!! even different approaches are welcome!!
--Josh