title: Why does realloc mess up the value?
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  void main()
  {
      int* list_of_numbers;
      list_of_numbers = (int*)malloc(1);
      list_of_numbers[0] = 10;
      printf("Value at 0 before realloc: %d", list_of_numbers[0]);
      list_of_numbers = (int*)realloc(list_of_numbers, 2 * sizeof(int));
      printf("Value at 0 after realloc: %d", list_of_numbers[0]);//this one prints -83920310 instead of 10
  
      system("pause");
  }
  </code></pre>
  
  <p>My assignment is asking me to allocate memory for one number and that works fine
  Then I need to reallocate it for 2 numbers to fit and as soon as I do that my first value is replaced by random value.
  Why? and how to fix :D</p>