Wednesday 16 March 2022

why local variable address do not as return type of function?

 The return statement should not return a pointer that has the address of a local variable. Because, as soon as the function exits, all local variables are destroyed and your pointer will be pointing to someplace in the memory that you no longer own.


Reference:

https://www.educative.io/edpresso/resolving-the-function-returns-address-of-local-variable-error

No comments:

Post a Comment