Hi, im currently trying to create a game whereby questions and are put into a binary tree, after a few branches of the tree the final leaf will be an object name (such as a cat). for the moment im just trying to create a binary tree populated with hard-coded questions and objects with a print statement just printing all of the elements in the tree in order to prove that the tree is correct, then i will move onto more difficult things such as getting the user to input the questions and objects.
so basically im having a lot of difficulty correctly creating the binary tree so any help you can provide would be greatly appreciated. my code so far is below.
Code:
#include <stdio.h>
#include<stdlib.h>
typedef struct node {
char object[200];
char question[200];
struct node *left;
struct node *right;
}treenode;
void insert(treenode **root,char question[]);
int main(void)
{
treenode* root=NULL;
insert(&root,("Does it have a tail"));
insert(&root->right,("Is it edible"));
insert(&root->left,("is it fluffy"));
printf("%d \n ",root);
printf("%d \n ",root->right);
printf("&d \n ", root->left);
return 0;
}
void insert(treenode **root, char question[]){
treenode *newnode;
newnode=(treenode*)malloc(sizeof(treenode));
newnode->right=NULL;
newnode->left=NULL;
}