title: realloc() not behaving as expected when shrinking char *
body: <p>I am attempting to shrink the pointer "ptr" with realloc() as show in this sample code:</p>
  
  <pre><code>char * ptr = malloc(sizeof(char) * 7);
  int i;
  for(i = 0;i&lt;7;i++){
      ptr[i]= "pointer"[i];
  }
  puts(ptr);
  ptr = realloc(ptr,sizeof(char) * 3);
  puts(ptr);
  free(ptr);
  </code></pre>
  
  <p>Expecting the code to free the unused memory i thought that it would return the following: </p>
  
  <pre><code>pointer
  poi
  </code></pre>
  
  <p>However, it instead returns this:</p>
  
  <pre><code>pointer
  pointer
  </code></pre>
  
  <p>Is this an error on the compiler's part, or is this an error in my understanding of realloc()?</p>