title: How to read unknown number of inputs?
body: <p>I am learning C++ using the book C++ Primer.</p>
  
  <p>In <em>Section 1.4.3</em>, the following example code about reading the unknown number of inputs is given.</p>
  
  <pre><code>#include &lt;iostream&gt;
  int main()
  {
    int sum = 0, value = 0;
    // read until end-of-file, calculating a running total of all values read
    while (std::cin &gt;&gt; value)
    sum += value; // equivalent to sum = sum + value
    std::cout &lt;&lt; "Sum is: " &lt;&lt; sum &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>According to the book, if we give an input of <code>3 4 5 6</code>, the output will be <code>Sum is: 18</code></p>
  
  <p>But when I try this on my computer(<em>Windows 10 with MinGW</em>), The code does not end. It just keeps on asking for input even if I enter a newline. It works only when I enter a non-int input like <code>f</code>.</p>
  
  <hr>
  
  <p><strong>Is this expected? If yes, is there any code that stops after inputting a newline?</strong></p>
  
  <p>I am quite new to c++ and I have already learned python, so getting stuck so early on is quite frustrating.</p>
  
  <hr>
  
  <p>Thanks and regards.</p>