title: Search and delete in double linked list
body: <p>I want to search something in a double linked list and delete it.</p>
  
  <p>My problem is that I lose both previous and the node of the node I want to delete.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>    int delnode(string moviename)
          {
              node *temp,*del;
              //check empty
              if(!head)
                  {
                      cout&lt;&lt;"empty";
                  }
              else
                  {
                      temp=head;
                  while (temp-&gt;next!=NULL)
                      {
  
                          if (temp-&gt;title==moviename)
                              {
                                  del=temp;
                                  temp=temp-&gt;previous;
                                  temp-&gt;next=del-&gt;next;
                                  delete del;
                              }
                          temp=temp-&gt;next;
                      }
                  }
          }
  </code></pre>
  
  <p>For example if I have 5 movies, movie1,movie2,movie3,movie4,movie5 and want to delete movie3 my list will be movie1,movie4,movie5 :S</p>