title: Read in space delimited numbers using scanf and storing them in an array - C
body: <p>I'm trying to take user input containing a bunch of space delimited 1-3 digit numbers using scanf() and storing them into an int array and printing each seperate one on a new line to test but it's not working. Here is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
    int sourceArr[500];
    int i = 0;
  
    printf("\nEnter ciphertext: \n");
    while (scanf("%d", &amp;sourceArr[i++]) == 1);
    for (int j=0;j&lt;500;j++) {
      printf("%d\n", sourceArr[j]);
    }
  }
  </code></pre>
  
  <p>so the user is asked to input a sequence of numbers like so:</p>
  
  <pre><code>Enter ciphertext: 
  23 122 32
  </code></pre>
  
  <p>and I want to store 23 in sourceArr[0], 122 in sourceArr[1] and 32 in sourceArr[2] and then print each one like so:</p>
  
  <pre><code>23
  122
  32
  </code></pre>
  
  <p>But the program idles right after entering the input and won't print the numbers.</p>