title: Trouble: C Declaration of integer array of unknown size
body: <p>I need to read unknown amount of various numbers on user's input using <code>scanf</code> function. That simply means the number of various integers is determined by the user by sending as many numbers as he can. Note that I read directly the numbers (I have to), as stated in following code:</p>
  
  <pre><code>int main(void)
  {
      int numbers[];
      int error = 0;
  
      int i = 0;
      while(scanf("%i", &amp;numbers[i++]) == 1);
  
      for(int i = 0; i &lt; sizeof(numbers) - 1; ++i) {
          if(numbers[i] &lt; -10000 || numbers[i] &gt; 10000)
          {
              printf("%i%s", numbers[i], ", ");
          }
          else
          {
              printf("%s", "\b\b\nError: Error: Vstup je mimo interval!\n");
              // Means "Input is out of range!".
              // We have to write exact output to terminal as stated in HW.
              i = sizeof(numbers);
              error = 1;
          }
      }
  
      ...
  }
  </code></pre>
  
  <p>The <code>int error</code> is actually a boolean value, but I am lazy to implement boolean library, so I define it as integer :D</p>
  
  <p>However, the problem is elsewhere. Compiler throws me an error:</p>
  
  <pre><code>main.c:7:9: error: array size missing in ‘numbers’
       int numbers[];
                  ^
  </code></pre>
  
  <p>Looks like that C program need to know the allocable size of an array. I already looked into some codes others have shared there to find out basics I need to implement and while searching for the array size issue, I found this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/15264613/c-declaring-an-array-with-an-undefined-value">C - Declaring an array with an undefined value</a></p>
  
  <p>However, it does not solve the problem with unknown array size for direct input of unknown amount of numbers. I found nowhere exactly I need to solve. I tried to define maximum size of array to hold up to 999 numbers, but then compiler throws me this exception:</p>
  
  <pre><code>main.c:50:23: error: iteration 999u invokes undefined behavior [-Werror=aggressive-loop-optimizations]
               if(numbers[j] &gt; 0)
                         ^
  main.c:48:9: note: containing loop
           for(int j = 0; j &lt; sizeof(numbers); ++j)
           ^
  </code></pre>
  
  <p>Same for every loop used for numbers statistics (total amount, maximum, minimum, odds, evens, positives, negatives, their percentage and average). That means the array is strictly size of 999 numbers with rest of numbers being zeros. I found out a <code>malloc</code> function, but do not understand its usage :(</p>