I write a function to search a tree, and find out the node suitable and store them in an array. It is in postorder.
But it can't work. Is there anything wrong in my code?
Thanks in advance!
void search_for_node(node *root, node *list[])
{
int j;
if (root == NULL)
return;
for(j=0; j<root->num_children; j++)
search_for_node(root->children[j], list);
if (root->type == ID)
list[num_for++] = root;
}
But it can't work. Is there anything wrong in my code?
Thanks in advance!