I made a mistake and used uninitialized local variable in a function and happened to find a single line of "cout" could change the uninitialized value. To simplify, I show the problem as follow.
#include <stdio.h>
void foo(void){
int i;
printf("%d\n", i);
i = 777;
}
int main(void){
foo();
//cout << "hello!" << endl;
foo();
return 0;
}
The line I comment out will change the output from (unknown#;777) to (unknown#;hello!;0). Could someone help explain? Thanks.