title: c++ getline doesn't get the input
body: <p>i am trying to input a line and then an integer then a line again however when it the last cin gets the line it and i press enter it crashes or outputs randomly to the infinity. whats wrong?</p>
  
  <pre><code>int main(){
      string a= "", b = "";
      int n1 = 0, n2 = 0;
  
      getline(cin, a);
      cin &gt;&gt; n1;
  
      //when i input the next like it outputs randomly without continuing with the next like why?
      getline(cin, b);
  
      //it doesn't let me to input here coz it's outputting some random strings.
      cin &gt;&gt; n2;
      return 0;
  }
  </code></pre>
  
  <p>I appreciate for your help, thanks.</p>