title: How does C free() work?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1119134/how-malloc-and-free-work">How malloc() and free() work</a>  </p>
  </blockquote>
  
  
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int * alloc()
  {
      int *p = (int *)calloc(5,4);
      printf("%d\n",p);
      return p;
  }
  
  int main()
  {
   int *p = alloc();
  
   free(p);
   printf("%d\n",p);
   p[0] = 1;
   p[1] = 2;
   printf("%d %d\n",p[0],p[1]);
  }
  </code></pre>
  
  <p>As to the code segment, I allocate 5 ints,first. And then I free the memory.
  When I printf p, why does p sill have a value same to the memory address allocated first?
  And I also can assign value to p[0] and p[1]. Does this mean free() do nothing? Once I
  allocate memory, I can use later though I have freed it.</p>