title: Removing a Node from a Doubly Linked List in C
body: <p>As a whole my program is for inserting and deleting nodes in a sorted doubly linked list. Insertion works and deleting the first node from the linked list works fine, except deleting the last node. Also, deleting nodes in the middle and end don't work. If I try to delete the last node, I am led back to main(); If I try deleting a node in the middle, the program crashes. Your help is appreciated! </p>
  
  <pre><code>void remove(int n){
      struct node* help = head;
      if(head-&gt;data == n){
          if (head-&gt;next)
              help-&gt;next-&gt;prev = NULL;
          head = help-&gt;next;
      } else{
          while(help){
              if(help-&gt;data == n){
                  if(help-&gt;next)
                      help-&gt;next-&gt;prev = help-&gt;prev;
                  help-&gt;prev-&gt;next = help-&gt;next;
              } else help = help-&gt;next;
          }
      }
  }
  </code></pre>