C语言静态变量

来源:互联网 发布:java工作流引擎有哪些 编辑:程序博客网 时间:2024/06/05 17:57
#include <stdio.h>
static int a=10;        //全局静态变量
void func();
int main(){
    while(a--){
        func();
    }
    return 0;
}
void func(){
    static int b=5;        //局部静态变量
    b++;
    printf("a=%d\tb=%d\n",a,b);
}
/***********************************************************
静态变量
1.全局变量每次调用时不会重置

************************************************************/

github:https://github.com/comeonjy/c

原创粉丝点击