title: free won't delete memory allocated to the pointer (int array), using free twice works, why?
body: <p>This is out of curiosity, I tried to find answers to my doubt on previous questions but they don't seem to have answer to it. So asking here, I just wrote a code where I am trying to allocate memory to an int pointer (to fill up an array) and scan int values to it. Once I am done with the array, I want to delete the data/memory allocated to the pointer. Although my code works fine and everything, why am I still able to see values inside int array even after free<em>ing</em> the pointer. Whereas, if I use free twice it throws up an error (which was expected after single use of free). Isn't this an odd behavior ? I tried it on my mac using Xcode also on codechef, same behavior, why ?</p>
  
  <pre><code>int *num=(int *)malloc(n*sizeof(int));
  int i;
  for(i=0;i&lt;n;i++)
  {
      scanf("%d",&amp;num[i]);        
  }    
  
  for(i=0;i&lt;n-1;i++){
      temp = some_function(x);        
  }
  
  free(num); 
  
  for(i=0;i&lt;n;i++)
  {
      printf("\nnum[%d]= %d\n",i,num[i]);        
  }
  </code></pre>
  
  <p>The above code prints values inside num[] which ideally it shouldn't. </p>