I was watching a lecture on returning local arrays vs dynamic arrays. When a local pointer variable(which was pointing to a static array) was returned by the function, a warning was there and its understandable because once the function call is over, that variable will be destroyed. But when that local variable was made to point at the dynamic array and returned at the end of the function, no warning was there. Please explain.
Dynamic and static memory allocation
hello @priyam04
dynamic memory dont get deallocated on its own even if the function call is over.
that is why we are allowed to send its base address without any trouble.