title: Doubly linked list: delete a node
body: <p>I'm trying to delete a node in a doubly linked list, but the problem here is that when I have the list: 7-6-5-4-3-2-1, and try to delete 3, I get 7-6-5-4-3, I can't figure out the error. Please help!</p>
  
  <pre><code>void RemoveItem(int itm)
  {           
      if (Head-&gt;item == itm) {
          Head = Head -&gt; Next;    
          cout&lt;&lt;"\nItem is at 1st node &amp; removed\n";flag=1;
      }
      else if (Head-&gt;Next == NULL) {          
          cout&lt;&lt;" \n This is 1-node list &amp; item not in it\n";
      }
      else {                  
          node *current, *del = Head; 
          while(del-&gt;Next != NULL &amp;&amp; del-&gt;item != itm) {
              del = del-&gt;Next;
          }
          current = del;
          current-&gt;Next = del-&gt;Next;
          del-&gt;Next-&gt;previous = current;
          delete(del);
          del-&gt;Next = NULL;
          flag = 1;
      }
  }
  </code></pre>