Question on allocating memory pointers inside a function. A pointer variable is passed as a parameter to a function. Memory allocation is done inside the function for the pointer using malloc. After coming out of the function, will the pointer still retain this address in the main program?
Anonymous
No. When pointer is passed as a function parameter, the address is copied like pass by value. Hence when it is out of the function, its address scope is last.
Check out your Company Bowl for anonymous work chats.