The problem with my code is that,when a left child value is searched then due do to recursion levels it goes back and checks the right child.And the return gets incorrect. I can't find a way to get past it.
node * search(node *ptr,int key)
{
    if(ptr->data==key)
        return ptr;
    else
    {
        if(ptr->lchild!='\0')
            search(ptr->lchild,key);
        else
            return '\0';
        if(ptr->rchild!='\0')
            search(ptr->rchild,key);
        else
            return '\0';
    }
}
 
     
     
     
     
     
    