title: How do free and malloc work in C?
body: <p>I'm trying to figure out what would happened if I try to free a pointer "from the middle"
  for example, look at the following code:</p>
  
  <pre><code>char *ptr = (char*)malloc(10*sizeof(char));
  
  for (char i=0 ; i&lt;10 ; ++i)
  {
      ptr[i] = i+10;
  }
  ++ptr;
  ++ptr;
  ++ptr;
  ++ptr;
  free(ptr);
  </code></pre>
  
  <p>I get a crash with an Unhandled exception error msg.
  I want to understand why and how free works so that I know not only how to use it but also be able to understand weird errors and exceptions and better debug my codeץ</p>
  
  <p>Thanks a lot</p>