c - Why local variable is initialized to zero -


according knowledge, local variables uninitialized i.e, contains garbage value. following program giving 0 (zero) output.

main() {     int i;     printf("%d\n",i); } 

when run above program giving 0. know 0 can garbage value every time getting 0 output. can know reason it?

when run above program giving 0. know 0 can garbage value every time getting 0 output.

whatever happened cause 0 written location i happens every time program runs. computers nice , reliable that. "garbage" doesn't mean "random" or "always changing," means "not meaningful in context care about."


Comments