title: reading an input(int) and storing it into an array with malloc and realloc
body: <p>I'm trying to read ints from stdin, but i don't know the length. I tried this but I have no idea why it doesn't work</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      int *arr = (int *) malloc(sizeof(int));
  
  
      int sizeCounter = 0;
      int tmp = 0;
      while(scanf("%d", &amp;tmp) != EOF)
      {   
  
          arr = (int *) realloc(arr, sizeof(arr)+sizeof(int));
          arr[sizeCounter] = tmp;     
          sizeCounter++;          
  
      }
  }
  </code></pre>
  
  <p>Error - realloc(): invalid pointer: 0xb76d8000 <em>*</em></p>