3 ms·
How about int x = 0 if you want 0. Just `int x;` doesn't make it clear that you want 0.
by frollogaston 1y ago
How about int x = 0 if you want 0. Just `int x;` doesn't make it clear that you want 0.
- kstrauser 1y agoSafe defaults matter. If you're using x to index into a array, and it's randomly initialized as +-2,000,000,000 because that's what happened to be in that RAM location when the program launched, and you use it before explicitly setting it, you're gonna have a bad time. And if you used it with a default value of 0, you're going to end up operating on the 0th item in the array. That's probably a bug and it may even be a crasher if the array has length 0 and you end up corrupting something important, but the odds of it being disastrous are much lower.
- conorjh 1y ago[dead]