title: Remove all nodes in linked list
body: <p>I have a linked list contains 3 nodes like the image shown:
  <img src="https://i.stack.imgur.com/EVmu1.jpg" alt="enter image description here"></p>
  
  <p>There is a head pointer and temp1 pointer point to the front of the list, and tail point points at the end of the list. </p>
  
  <p>I want to remove all the nodes, and change it back to its original initial form ( tail = NULL, head = first_node , but the first node doesn't have any value in the data and next field). </p>
  
  <p>Because I want to start putting up some new values in it. To remove all those data, is this code going to remove nodes inside this linked list and left with the first node with no values in data and next field? </p>
  
  <p>This code is in C++:</p>
  
  <pre><code>while(temp1!=tail)
  {
      temp1 = temp1-&gt;next;
      if(temp1-&gt;next == tail)
      {
          tail=temp1;
          temp1 = temp1-&gt;next;
          free(temp1);    
      }
  }
  </code></pre>
  
  <p>But then, does this mean only the last node will be deleted? are there any way to delete all the nodes except the first one?</p>