title: Using getline(cin, s) after cin
body: <p>I need the following program to take the entire line of user input and put it into string names:</p>
  
  <pre><code>cout &lt;&lt; "Enter the number: ";
  int number;
  cin &gt;&gt; number;
  
  cout &lt;&lt; "Enter names: ";
  string names;
  
  getline(cin, names);
  </code></pre>
  
  <p>With the <code>cin &gt;&gt; number</code> command before the <code>getline()</code> command however (which I'm guessing is the issue), it won't allow me to input names.  Why?</p>
  
  <p>I heard something about a <code>cin.clear()</code> command, but I have no idea how this works or why this is even necessary.</p>