title: Why does std::getline() skip input after a formatted extraction?
body: <p>I have the following piece of code that prompts the user for their cat's age and name:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main()
  {
      int age;
      std::string name;
  
      std::cin &gt;&gt; age;
      std::getline(std::cin, name);
      
      if (std::cin)
      {
          std::cout &lt;&lt; &quot;My cat is &quot; &lt;&lt; age &lt;&lt; &quot; years old and their name is &quot; &lt;&lt; name &lt;&lt; std::endl;
      }
  }
  </code></pre>
  <p>What I find is that the age has been successfully read, but not the name. Here is the input and output:</p>
  <blockquote>
  <pre><code>Input:
  
  &quot;10&quot;
  &quot;Mr. Whiskers&quot;
  
  Output:
  
  &quot;My cat is 10 years old and their name is &quot;
  </code></pre>
  </blockquote>
  <p>Why has the name been omitted from the output? I've given the proper input, but the code somehow ignores it. Why does this happen?</p>