View Single Post
Light Poster
23Feb2010,12:00  
sganesh's Avatar
int *p=(int *)malloc(12);
free(p);

Your question is whether calling free function with argument p will clear the remaining elements.

It won't Because free will clear the first location which is pointed by p. 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.