I know that sometimes if you don\'t initialize an int
, you will get a random number if you print the integer.
But initializing everything to zero seems
In general, there's no need to initialize a variable, with 2 notable exceptions:
Beyond that, it's about getting the variables into the right state that you want them in for the operation you're going to perform. If you're not going to be reading them before an operation changes their value (and the operation doesn't care what state it is in), there's no need to initialize them.
Personally, I always like to initialize them anyway; if you forgot to assign it a value, and it's passed into a function by mistake (like a remaining buffer length) 0 is usually cleanly handled - 32532556 wouldn't be.