0
[C] Why does i become 9?
int i = 10; void f(void){ int i = 5; i = 7; } void g(){ i = 9; } int main(){ i = 1; g(); f(); printf("%d", i); return 0; }
1 Antwort
+ 5
int main(){
i = 1;
// here i becomes 1
g();
//here i becomes 9
f();
//here the local variable i becomes 7 so the global variable i remains 9
printf("%d", i);
//so here it comes 9
return 0;