title: Better way to break out of while loop? C
body: <p>I need to create a singly linked list based on user input which adds to the front of the list and is based upon user input.  I have completed the program, but I am, for some reason, running a blank on one smaller part with the user input here:</p>
  
  <pre><code>    while(numInput != -1)
  {
      cout &lt;&lt; "Enter a number: ";
      cin &gt;&gt; numInput;
      if(numInput != -1)
      {
          theList-&gt;addToHead(numInput);
      }
  }
  </code></pre>
  
  <p>I know there is a better way to write this even though it does the correct thing.  If I don't have the IF statement within the while loop, it will add "-1" to the list and I don't want that.  So this code works, but I feel it should be written differently.  I messed around with different loops but cannot think of it right now.  Thanks in advance.</p>