主页
C 语言
C 变量作用域
demo_scope_global2
运行 ❯
×
更改方向
保存代码
更改主题
#include
// Global variable x int x = 5; void myFunction() { // Local variable with the same name as the global variable int x = 22; printf("%d\n", x); // Refers to the local variable x } int main() { myFunction(); printf("%d\n", x); // Refers to the global variable x return 0; }
22
5