title: Unable to read two strings with cin.get()
body: <p><img src="https://i.stack.imgur.com/rSHsq.png" alt="sample execution">Why does trying to input two strings using cin.get() fails? I can successfully read the first string but the input fails for second string and subsequent operations.. See the code:</p>
  
  <pre class="lang-c++ prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  
  int main(){
  long int n,k;
  char a[11],b[11];
  cin.get(a,11);
  
  n = atoi(a);
  
  cin.get(b,11);
  cout&lt;&lt;b;   
  k = atoi(b);
  
  
  cout      &lt;&lt; "\ncin.rdstate(): " &lt;&lt; cin.rdstate()
        &lt;&lt; "\n    cin.eof(): " &lt;&lt; cin.eof()
        &lt;&lt; "\n   cin.fail(): " &lt;&lt; cin.fail()
        &lt;&lt; "\n    cin.bad(): " &lt;&lt; cin.bad()
        &lt;&lt; "\n   cin.good(): " &lt;&lt; cin.good() &lt;&lt; endl &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I am trying to input two strings and store them into long int variables as shown in program, but the <code>cin.get(b,11)</code> fails and stack overflow occurs for
   <code>k= atoi(b)</code> .Also, you may observe nothing is output for <code>cout&lt;&lt;b</code> .. And, at last <code>cin.fail()</code> is set to 1 , which means I am doing some kind of logical error.. Please help me in rectifying this!
  Please suggest some method which is fast and meant for c++ only ..
   (If you  feel this question is too bad please mention in comments before down voting this, I am already struggling at 21 rep!)</p>