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;
     }
    }

Recommended Answers

All 2 Replies

what are the compiler errors?

it would be better if you can align your code first with respect to { and }

)// ai is the value we are looking for in the linklist . bi is the value od the new node

Is this one line or 2 line

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.