title: Why will cin split a floating value into two parts?
body: <p>I have a problem about cin.</p>
  
  <pre><code>int main(void)
  {
      int a;
      float b;
      cin &gt;&gt; a &gt;&gt; b;
  }
  </code></pre>
  
  <p>When I give a floating number (such as 3.14) as input, neither <code>a</code> nor <code>b</code> get the complete value (3.14): the output is a=3, b=0.14.</p>
  
  <p>I know that <code>cin</code> will split the input by space, tab or Return, but 'dot' will not, right? </p>
  
  <p>And why will the following code work?</p>
  
  <pre><code>int main(void)
  {
      int i=0;
      int k=0;
      float j=0;
  
      cin &gt;&gt; i &gt;&gt; k &gt;&gt; j;    // i =3, j=k=0
  }
  </code></pre>
  
  <p>And one more problem, what benefit will compiler do this for us?</p>
  
  <p>Thanks!</p>