If I have a function, such as a delete function for a binary search tree, and I want to change the root node, which is a pointer within main(), The only way I read I could do that would be to pass a pointer to that pointer.
for instance....
void someFunc(node **root, int key);
I am a little confused in how this should be used. I keep getting "Request for member in something not structure or union" with the following.
Code:
void delete(b_tree **tree, t_node *node, int key)
{
//code in here
if(target == tree->root)
tree->root = tmp; //i think it should be *tree->root
//later on
tree->size++;
}
Any help on getting these pointers set right would be appreciated.
EDIT: I initially thought this would work....
Code:
if (target == *tree->root)
*tree->root = tmp;
//later
*tree->size++;