title: Why is cin.ignore() necessary when using "getline" after "cin", but is not required when using "cin" multiple times?
body: <p>In my knowledge when using <code>getline()</code> after <code>cin</code>, we need to flush the newline character in the buffer first, before calling <code>getline()</code>, and we do this by calling <code>cin.ignore()</code>.</p>
  
  <pre><code>std::string name, address;
  
  std::cin &gt;&gt; name;
  std::cin.ignore(); //flush newline character
  getline(std::cin,address);
  </code></pre>
  
  <p>But when using multiple <code>cin</code>, we do not need to flush the newline character.</p>
  
  <pre><code>std::string firstname, lastname;
  
  std::cin &gt;&gt; firstname;
  std::cout &lt;&lt; firstname &lt;&lt; std::endl;
  
  //no need to flush newline character
  
  std::cin &gt;&gt; lastname;
  std::cout &lt;&lt; lastname &lt;&lt; std::endl;
  </code></pre>
  
  <p>Why is that? Why is <code>cin.ignore()</code> necessary in the first case, but not the last?</p>