/*
filename:local variable and global variable
function:introduce the difference of the local variable and the local variable
*/
# include <stdio.h>
int count;
void func1();
void func2();
int main(void)
{
count = 100;
func1();
return 0;
}
void func1()
{
int temp;
temp = count;
func2();
printf(" count is %d\n", count);
func2();
}
void func2()
{
int count;//define a local variable.when the local variable is the same as global variable,
//the function use the local variable,not the global variable
for(count=1; count<20; count++)
{
printf(".");
}
printf("\n");
}
/*
在函数内部定义的变量,仅在函数内部有效,称为内部变量或者局部变量
在函数外部定义的变量,是全局变量,可以被文件域内其他函数使用
它的有效范围是从定义变量的位置开始到源文件结尾
*/
result: