You asked what parts of what you said were false. Just about every point you made was false.
> Because free will clear the first location which is pointed by p.
False. If p=malloc(x) then free(p) will free *ALL* x bytes. Not just the first.
> If you want to clear all locations that is allocated by malloc. you need to use loop you need to have the temporary pointer then freeing it then move to the next pointer.
False. If p=malloc(x) then free(p) will free *ALL* x bytes. My post suggested you may have confused this with allocating an array of pointers then individually mallocing each of those pointers. In that case, yes you will need to free each individual pointer before freeing the array of pointers. But your argument is that if p=malloc(x) then to free this you need free(p), free(p+1), free(p+2), ..., free(p+x-1) in order to free all x bytes. THIS IS FALSE. If you think it's true, what is your source? Where did you get this idea from?
> free(p) will free the 12 bytes that were allocated by malloc(12) I also said that it is false. It will free only one pointer(location) that is pointed by p.
Wrong again. If p=malloc(12) then free(p) will free *ALL* 12 bytes. You *DO NOT* need 12 calls to free().
You don't have to take it from me (a site Mentor with over 1000 posts) and shabbir (the site Admin) who both disagree with you. You can also take it from:
Wikipedia
http://en.wikipedia.org/wiki/Malloc which states "free(void *pointer) ... releases the block of memory pointed to by pointer"
the Gnu documentation
http://www.gnu.org/s/libc/manual/htm...er-Malloc.html
cplusplus.com:
http://www.cplusplus.com/reference/c.../cstdlib/free/
It's perfectly OK that you've misunderstood something, hence my asking "where did you get this wrong idea from" so that we could perhaps help you see how you've misunderstood.