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 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: which one is right?

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论