Work in HR? Unlock Free Profile

Broadcom Staff Engineer Interview Question

I interviewed in Matawan, NJ and was asked:
"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?"
Add Tags [?]

Part of a Staff Engineer Interview Review - one of 346 Broadcom Interview Reviews

Answers & Comments

of 0
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.
- Interview Candidate on Jun 28, 2012

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.