title: How does realloc() reallocate the memory?
body: <p>How does <code>realloc()</code> reallocate the memory which was first allocated by <code>malloc()</code>? </p>
  
  <p>I know that you need to use <code>malloc()</code> before you´re able to reallocate the memory, but I don´t understand how that really should work. What if a dynamic-memory object gets decreased in size by <code>realloc()</code>? Is this respective piece of the object just erased after the call to <code>realloc()</code>?</p>
  
  <hr>
  
  <p>My Question is:</p>
  
  <ol>
  <li>How does the <code>realloc()</code> function reallocate a dynamic-memory object created by <code>malloc()</code>? 
  
  <hr></li>
  </ol>
  
  <p>Note: I did this Q&amp;A because many beginners seem to be still confused about the issue of reallocating memory using <code>realloc()</code> despite already existing questions here on SO for that topic. They seem to be a little confusing for anyone who is new to the topic and still do not represent the whole behavior of <code>realloc()</code>. Therefore, and because the questions, IMHO, still do not quite fit the answer I´d want to give, I made my own Q&amp;A. </p>