free dynamic allocation | Sololearn: Learn to code for FREE!


free dynamic allocation

how to know if this memory is freed in c ex: int *p=malloc(sizeof(int)); free(p); after that how to know if this memory is freed

5/23/2019 10:47:15 AM


2 Answers

New Answer


its definitely free, but if you have a doubt, just use an if statement to check if the value of the pointer is NULL then the memory is freed, i guess you know how to do that edit: am not sure they is a way to check this, but after freeing the pointer you can assign the pointer to NULL


p will not be null after free call because I pass p by value so p will not affected