1,3 are correct but 2 is wrong.

guest (willcome)
In 1), 3) the address of somewhere in the static data area will be returned.
But in 2), p is the address of the array, which is allocated on the stack and in one stack frame. After the function 'v()' is returned the stack frame
is removed (or become invalid), thus the address of the array (i.e. 'p') becomes an invalid address.
2001-5-15 -05:00

回到话题: which one is right?

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论