+ 2
int x; x +=10; spits out 4309688. Explanation?
2 odpowiedzi
+ 9
x is not intialised with a value. It could point anywhere in memory. You should always initialise/insert values into variables before using them.
try
int x=0;
x +=10;
+ 7
You have created the variable but not initialised it. when you type int x; it allocates some memory but does not automatically set the variable to zero (you usually end up with some random value based on what that bit of memory was holding previously).
You should initialise it using something like int x=0;