Your program behaviour is undefined since %s
is not a valid format specifier for an int
.
Exactly why it gives you the values it does is down to conjecture. The compiler also reserves the right to eat your cat. And your dog given that void main()
is not compliant with later C standards.
C intentionally does not guard against your doing this as that would compromise the performance of the language. It's difficult (although not impossible as C is statically typed) for a compiler to warn you of this.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…