7.19 函数II Day12
---note--- auto 自动 register 寄存器 static 静态的 extern 外部 ---note---
#include<stdio.h>
int f(int a);
int main()
{ int a=2,i;
for (i=0;i<3;i++) printf("%4d",f(a));
return(0);
}
int f(int a)
{ int b=0;static int c=3;
b++;c++;
return(a+b+c);
}
//最后输出的结果为:7 8 9
(静态局部变量只能在函数中使用,但是它具有记忆性,即下一次进入这个函数,它的值时保持上 一次使用的值)