Hello everyone! I'm new here, and I have this project that I'm supposed to do with C++. So, I have this txt file that has
question : Is it a feline?
object : cat
question : Is it a canine?
object : dog
object : pangolin
And, from that txt file, I have to create it like this
---------------------- Is it a feline?
-------------------/ ------------------\
-----------------Cat ----------------Is it a canine?
------------------------------------/---------------\
---------------------------------Dog--------------Pangolin
I'm really torn about this because my building code has recursion but I don't know where to put the return, you can check the code here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
tree *loading()
{
tree *ptr;
fgets(qoro,100,data2file);
if(qoro==NULL)
{
return NULL;
}
else
{
ptr=new tree;
ptr->question[0]='\0';
ptr->object[0]='\0';
ptr->yes=NULL;
ptr->no=NULL;
if(qoro[0]=='q')
{
strcpy(ptr->question,qoro);
if(root==NULL)
{
root=ptr;
}
ptr->object[0]='\0';
ptr->yes=loading();
ptr->no=loading();
}
else
{
strcpy(ptr->object,qoro);
ptr->question[0]='\0';
ptr->yes=NULL;
ptr->no=NULL;
}
}
}
|
It actually works fine, is just that the nodes won't connect. Any help? :(