ProAnswers.org

Is the allocated space within a function automatically deallocated when the function returns?

No pointer is different from what it points to .Local variables including local pointers

variables in a function are deallocated automatically when function returns. But in case of a

local pointer variable ,deallocation means that the pointer is deallocated and not the block of

memory allocated to it. Memory dynamically allocated always persists until the allocation is freed

or the program terminates.