15 lines
334 B
C
15 lines
334 B
C
|
#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;
|
||
|
}
|