I'm writing a function to insert into a tree and the data can be seen (printed) after insertion within the function but when trying to see it in main nothing happens.
node *tree = NULL;
insert(tree, 4321);
printf("outer: %d\n", tree->data);
void insert(node* tree, int data) {
if (tree == NULL) {
tree = new_node(data);
printf("inner: %d\n", tree->data);
}
}
This gives:
inner: 4321
It should be:
inner: 4321
outer: 4321