qfedu-c-level/day7/d1.c

15 lines
334 B
C
Raw Normal View History

2023-07-11 19:52:53 +08:00
#include <stdio.h>
void show()
{
int x = 10; // x 只在 show() 函数中有效
printf("show x = %d\n", x);
}
int main(int argc, char const *argv[])
{
int x = 100;
show(); // show 函数内的变量则会自动释放
printf("main x = %d\n", x); // x 是 main 局部定义的 x
return 0;
}