this is my code :
#include <stdio.h>
void foo(void)
{
int i;
printf("%d\n", i);
i = 777;
}
int main(void)
{
foo();
//printf("hello\n");
foo();
return 0;
}
it show :
-1079087064
777
but if you remove the // in the code , it will be show :
134513817
hello
13541364
so why it show 777 when first time ,
thanks
What you are doing is undefined behavior. You are printing the value of an uninitialized variable. The number could be based on whatever was previously in the memory location of that variable.