title: How to delete a node in a linked list?
body: <p>This is what I have so far, but it's not working. Basically skips to <code>else if(cnode == preposition)</code>.</p>
  <pre><code>void LinkedList::Delete(Node *PrePosition) {
  
      Node *cnode = head;
      Node *pnode = NULL;
      while (cnode != NULL) {
          if (cnode-&gt;value != NULL) {
              if (pnode == NULL) {
                  // if there is not previous node
                  head = cnode-&gt;next;
              }
              else if (cnode == PrePosition) {
                  // if there is previous node
                  cout &lt;&lt; endl &lt;&lt; &quot;Deleting: &quot; &lt;&lt; cnode &lt;&lt; endl;
                  pnode-&gt;next = cnode-&gt;next;
              }
          }
          else {
              // don't delete
              pnode = cnode;
          }
          cnode = cnode-&gt;next;
      }
  }
  </code></pre>