Searching in Binary tree

how to get the address of the target node in Binary Tree
My code is following

node *search_target_node(node *root,int target)
{
if(root==NULL)
{
return NULL;
}
if(root->data==target)
return root;
root= search_target_node(root->left,target);
root= search_target_node(root->right,target);
return root
}

@mohitmcanitt actually, in this code, if root is in left subtree, it gets overwritten by next line when you get either root, or NULL from the right subtree, so you can modify the last lines like
root = searchTarget(root->left);
if (root != NULL) {
return root;
}
root = searchTarget(root->right);
return root;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.