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;
i=2;
child = parent->children[i];
parent->children[i] = NULL;

      

+3


source to share


1 answer


Am I doing it right?

Assuming 2

less FIXED_SIZE

, your code looks fine.




Referring to your wording:

I want to have a child inside a child variable

child

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

+2


source







All Articles