void disptree(node *ptr)
{
if ((ptr->left) !=NULL)
disptree(ptr->left);
cout<<"Position:"<<ptr->pos<<" Data:"<<ptr->data<<endl;
if ((ptr->right)!=NULL;
disptree(ptr->right);
}
i'm getting a segmentation fault at the red line. i cannot understand what's the problem. Help me out.
Thanks in advance..
vino
February 19, 2010, 1:47am
2
You may also want to check if ptr is null or not. Something like
if (ptr && (ptr->left) !=NULL)
And likewise with ptr->right.
Hi Vijay,
You are passing a pointer to this function. Ensure that the pointer is valid from where you called this fuction. It should not be pointing to deleted are freed objects.
-Vijay
Thank u for ur time ppl. made a mistake at other part of prog so null was being to ptr...