Removing a pointer from an array of pointers

I am creating a tree data structure in which I have an array of pointers at each node ( node* children[FIXED_SIZE]

) that points to children (array size is fixed):

I want to have a child inside a variable child

(without freeing the memory associated with it), but I also want to remove the reference between the parent and the children. Am I doing it right?

node* child = NULL;
child = parent->children[i];
parent->children[i] = NULL;



source to share

1 answer

Am I doing it right?

Assuming 2


, your code looks fine.

Referring to your wording:

I want to have a child inside a child variable


does not have a "child inside" but rather a link points to one.



All Articles