Behavior of uninitialized local char?

前端 未结 3 1798
挽巷
挽巷 2021-01-19 06:31

If you have lets say a local int that is uninitialized, then its gets an undefined value but if you have a local char variable should that not have

3条回答
  •  灰色年华
    2021-01-19 06:53

    Local variables get their initial values from whatever random data is in the stack space they occupy at that moment. There is no guarantee that space contains zeros.

提交回复
热议问题