title: Reading integers in C until the ENTER key is pressed
body: <p>I'd like to read a variable number of integers in an array until the user hits Enter. I have managed to achieve this by doing the following: </p>
  
  <pre><code>printf("Give the numbers in the array, then hit ENTER: \n");
  scanf("%d", &amp;array[i]);
  i++;
  no_elements++;
  
  while (scanf(line, "%d", &amp;array[i++])== 1) {
      scanf("%d", &amp;array[i]);
      i++;
      no_elements++;
  }
  </code></pre>
  
  <p>On the other hand, I found this on a website and I don't fully understand the scanf test. It works in that the reading stops when I hit enter. However, the number of integers read ends up being equal to one regardless (checked that by adding a printf instruction). Why is that? How else could I do the same?</p>
  
  <p>Note: the variable i is set as 0 in the beginning, as is no_elements; line is declared as char line[20]. </p>