title: Does free() remove the data stored in the dynamically allocated memory?
body: <p>I wrote a simple program to test the contents of a dynamically allocated memory after free() as below. (I know we should not access the memory after free. I wrote this to check what will be there in the memory after free)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  main()
  {
      int *p = (int *)malloc(sizeof(int));
  
      *p = 3;
      printf("%d\n", *p);
      free(p);
  
      printf("%d\n", *p);
  }
  </code></pre>
  
  <p>output:
      3
      0</p>
  
  <p>I thought it will print either junk values or crash by 2nd print statement. But it is always printing 0.</p>
  
  <p>1) Does this behaviour depend on the compiler?</p>
  
  <p>2) if I try to deallocate the memory twice using free(), core dump is getting generated. In the man pages, it is mentioned that program behaviour is abnormal. But I am always getting core dump. Does this behaviour also depend on the compiler?</p>