C语言学习(17)

 1 //static的用法
 2 #include<stdio.h>
 3 void f(int a){
 4     static int b=2;
 5     b=a+b;
 6     printf("a=%d,b=%d\n",a,b);
 7 }
 8 
 9 int main(){
10     int a=1,i;
11     for(i=1;i<=3;i++){
12         f(a);
13     }
14     return 0;
15 }

猜你喜欢

转载自www.cnblogs.com/Tobi/p/9237572.html