Why uninitialized variable print a strange negative value? [duplicate]

What you’re doing (reading the value of an uninitialised variable) is undefined behaviour; anything can happen, from it appearing to work, to printing random values, to crashing, to buying pizza with your credit card.

Leave a Comment