title: recognizing both space delimiter and newline character in C or C++
body: <p>In programming competitions, often the input given is of the form:</p>
  
  <pre><code>1 3 5 544
  4 
  2 3 22
  2423 
  2 
  </code></pre>
  
  <p>where there are multiple lines of integers delimited by a space. I've been trying to figure out how to read these input in C or C++ but could never really get it to work. Solutions that I've found on the web either use scanf or getline (or fget) but whenever I tried, they either failed to recognize the newline character or, when I tried to use them in conjunction with a for loop, the first iteration wasn't executed.</p>
  
  <p>How do the competitive programmers read this type of input?</p>