It give me core dump error after I have create a child in my binary tree, the if condition work perfectly, but when I try to pass the sx child as parameter it give error and I don't know how to fix it.
#include <stdio.h>
#include <stdlib.h>
typedef struct nodes *node;
struct nodes{
int dato;
node sx;
node dx;
};
node build(node n){
printf("Insert the value: ");
scanf("%d",&n->dato );
char s[5];
printf("build a child? ");
scanf("\n%s",s);
if(s[0]=='l')
build(n->sx);
return n;
}
int main(int argc, char const *argv[]) {
system("clear");
node root=(node)malloc(sizeof(node));
root=build(root);
printf("\n\nvalue: %d\n", root->dato);
return 0;
}