Local variable still exists after function returns

前端 未结 5 2179
暖寄归人
暖寄归人 2021-01-05 20:00

I thought that once a function returns, all the local variables declared within (barring those with static keyword) are garbage collected. But when I am trying

5条回答
  •  死守一世寂寞
    2021-01-05 20:32

    There's no garbage collection in C. Once the scope of a variable cease to exist, accessing it in any means is illegal. What you see is UB(Undefined behaviour).

提交回复
热议问题