Question 4 Pointers

How is this a memory leak?

Hey Harsh, the problem is memory leak because p is allocated some memory which is not freed, but the pointer is assigned as NULL. The correct sequence should be

free ( p );
p = NULL;

Hey Harsh, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “Ask Doubt” section, when your doubt is resolved.