iv written a code that insert a node befor a node containing a certain value(for example insert a node having value 3,befor the node containing value5),i checked the code many times,i couldnt find any mistake, but the compiler errors this part. can any one help.
here is the code :
void insert_b4_search(int ai,int bj)// ai is the value we are looking for in the linklist . bi is the value od the new node
{ node *temp;
temp = head;
while(temp != NULL && temp-> num != ai)//num=value
{temp = temp -> nxt;
if(temp == NULL){
cout<<"ooo"<<endl;
} }
if (temp == head){
insert_at_first(bj);//call add at first method
}
else if(temp == tail){
insert_to_tail(bj);
}
else { ptr = new node(bj,NULL,NULL);
ptr->prev = new node(bj, ptr->prev, ptr);
ptr->prev->prev->next = ptr->prev;
}
}