In the second one, you're setting a value to 0, then incrementing inc
, so the value you print out is the one just after what you just set to 0. Since it hasn't been initialized (yet), it produces arbitrary ("random") values.
It also prints out the value one past the end of the array, giving undefined behavior when it does so.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…