trying to make a search function in doubly Linklist but getting error on runtime.....

void search(int srch)
{
if (isempty())
{
cout<<"No Record Found";
}
else
{
node *p;
p=head;
while(p!=NULL || p->getroll_no()==srch)
{
p=p->getnext();
}
if(p==NULL)
{
cout<<"No Record Found";
}
else
{
cout<<"\nRoll Number is: "<<p->getroll_no()<<endl;
cout<<"Marks are: "<<p->getmarks()<<endl;
cout<<"Name is: "<<p->getname()<<endl;
}
}
}
The condition on the while loop is invalid. Shall be

while ( p != NULL && p->getroll_no() != srch )
Topic archived. No new replies allowed.