title: Increasing array size dynamically in C
body: <p>I need to increase length of 2 arrays according to user input. I'm using the code below. But output is not matching with user input. </p>
  
  <pre><code>    #include&lt;stdio.h&gt;        
      int main()
      {
          int i=0, key=0, size[key], time[key];
  
          while (key!=-1)
          {
               printf("Insert value for size : ");
               scanf("%d",&amp;size[i]);
               printf("Insert value for time : ");
               scanf("%d",&amp;time[i]);
               i++;
  
               printf("Run again Press-1 or Exit  : ");
               scanf("%d",&amp;key);
          }
  
          int x=0;
          for (x ; x&lt;i ; x++)
          {
               printf("%d %d\n",size[x],time[x]);
          }
          return 0;
      }
  </code></pre>
  
  <p>When user inputs the values:</p>
  
  <pre><code>    35 4
      20 3
      40 1
      60 7
      20 8
  </code></pre>
  
  <p>Then this is the output:</p>
  
  <pre><code>    8  4
      20 3
      40 1
      60 7
      20 8
  </code></pre>
  
  <p>If length of array exceeded 4, the last element of the <code>time</code> array will be printed as the first element of the <code>size</code> array. </p>
  
  <p>Why does my program give this output?  </p>