Does an int in Objective-C have a default value of 1?

前端 未结 4 1317
刺人心
刺人心 2020-12-19 13:29

I have this simple line of code:

int x;

x automatically has the value of 1. I don\'t set it to anything but when I debug, it s

4条回答
  •  误落风尘
    2020-12-19 13:44

    No, on the contrary, x has no default value at all. What you're seeing is the garbage that the variable was placed upon when you created it.

提交回复
热议问题