Why we must initialize a variable before using it? [duplicate]

Because, unless the variable has static storage space, it’s initial value is indeterminate. You cannot rely on it being anything as the standard does not define it. Even statically allocated variables should be initialized though. Just initialize your variables and avoid a potential headache in the future. There is no good reason to not initialize a variable, plenty of good reasons to do the opposite.

On a side note, don’t trust any book that claims to teach you X programming language in 21 days. They are lying, get yourself a decent book.

Leave a Comment