I am building a tree data structure, in which I have an array of pointers in every node (node* children[FIXED_SIZE]), that point to children (size of the array is fixed):
I want to have a child inside the child variable (without freeing memory associated with it) but I also want to delete link between parent and children. Am I doing it correctly?
node* child = NULL;
i=2;
child = parent->children[i];
parent->children[i] = NULL;
Am I doing it correctly?
Assuming 2 is less then FIXED_SIZE, your code looks ok.
Referring your wording:
I want to have a child inside the child variable
child does not "have a child inside" but references, points to one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With