title: Dynamic memory allocation of integer array
body: <p>I am trying to create an array of size 2, dynamically, using malloc. Here is my code:</p>
  
  <pre><code>int *d = (int*)malloc(2 * sizeof(int));
  d[0] = 4;
  d[1] = 5;
  d[2] = 8;
  d[3] = 9;
  d[4] = 7;
  int i;
  
  for (i = 0; i &lt; 5; i++)
     printf("%d \n", d[i]);
  </code></pre>
  
  <p>When I run this code, it prints <code>4, 5, 8, 9, 7</code>. </p>
  
  <p>I am wondering how it was able to allocate more memory (5 integers) than I requested (2 integers)?</p>