In the following code i am getting compilation error:c2227:left of -> left must point to class/struct/union/generic type. any help how to fix this; I am trying to insert in a binary tree.
typedef struct bnode{
int key;
struct bnode* left;
struct bnode* right;
}BNODE;
void printKeysReverse(BNODE* current);
void inorder(BNODE* current);
void insert(BNODE **root,int key);
int main(void){
BNODE* root=NULL;
insert(&root,27);
insert(&root,59);
insert(&root,21);
insert(&root,38);
insert(&root,54);
insert(&root,63);
insert(&root,8);
insert(&root,70);
insert(&root,15);
}
void insert(BNODE **root, int val){
BNODE *newnode;
newnode=(BNODE*)malloc(sizeof(BNODE));
newnode->right=NULL;
newnode->left=NULL;
if ((*root)==NULL){
*root=newnode;
(*root)->key=val;
return;
}
if (val<(*root)->key) insert((&root)->left,val);
else insert((&root)->right,val);
}//end
(&root)->left
&root is NOT a BNODE*