This is the framework of my program (without the code of functions). It is meant to build a binary tree. My question i about the scanf with pointer to struct. In current code, though it is compiled, it is crushed in the scanf stage when debug it.
where is my mistake?
Code:struct tree_el {
int val;
struct tree_el * right, * left;
};
typedef struct tree_el node;
void main() {
node *curr=NULL, *root= NULL;
printf("please enter a number\n");
scanf ("%d", curr->val);
while (curr->val!=0)
{
curr = (node *)malloc(sizeof(node));
curr->left = curr->right = NULL;
printf("please enter next number\n");
scanf ("%d", curr->val);
insert(&root, curr);
}
TIA.