I just reformatted your code, and one thing springs to mind: it's not (necessarily) your delete code: your build code is very, very faulty as well:
node *binary_tree(node *p, int data)
{
node *temp;
if(p==NULL)
{
p=new node;
p->data=data;
p->left=p->right=NULL;
}
else if(data>(p->data))
{
p->right=binary_tree(p->right,data);
}
else
{
p->left=binary_tree(p->left,data);
}
}
Look at this code: you use it to build a new tree. What doesn't happen here that should?
Hint:
node *binary_tree(node *p, int data)
Declares a function returning a pointer to a node. What value does this function actually return? Where does it return it?
How did you get this to compile, never mind run?