rebuilding tree from file
<p>I have problem in connecting nodes for my tree. In my program the function <code>read()</code> will be executed first then the <code>load()</code> function. In <code>read()</code> function all data from my external file will be stored in array then rebuild in <code>load()</code> function. Variables <code>dat</code> and <code>i</code> was declared globally. My problem is on the <code>load()</code> function. your help is really appreciated.By the way my data on the external file was arranged pre-orderly and I used "#" for NULL nodes.     </p>

<pre><code>void read()
{
    string dat1;
    fstream file;
    file.open("data.txt", ios::in);
    do
    {
       getline(file,dat1);
       dat[i]=dat1;
       i++;
    }while(!file.eof());
    file.close();
}

void load(node *root,int index)
{

    node *nNode;
    nNode=(node*)malloc(sizeof(node));
    nNode-&gt;yes=NULL;
    nNode-&gt;no=NULL;

    nNode-&gt;data=dat[index];

    if(index&lt;i)
    {
        if(nNode-&gt;data!="#")
        {
            root=nNode;
            load(root-&gt;yes,index+1);
            load(root-&gt;no,index+1);
        }
        else
        {
            root=NULL;
            return;
        }
    }
}
</code></pre>
