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
Static and global variables will be initialized to zero for you so you may skip initialization. Automatic variables (e.g. non-static variables defined in function body) may contain garbage and should probably always be initialized.
If there is a non-zero specific value you need at initialization then you should always initialize explicitly.