Chinaunix首页 | 论坛 | 博客
  • 博客访问: 411923
  • 博文数量: 93
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 1052
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-19 11:01
文章分类

全部博文(93)

文章存档

2011年(1)

2009年(26)

2008年(66)

我的朋友

分类: LINUX

2008-12-15 17:00:36

static的"局部变量,全局寿命"的用法通过下面的例子来体现:
int test(void)
{
   int a=0;
   a++;
    printf("a=%d\n",a);
    
   return 0;
 
}
 
int test1(void)
{
   static int b=0;
   b++;
   printf("b=%d\n",b);
  
   return 0;
}
 
int main(void)
{
   test();
   test();
   test();
   test1();
   test1();
   test1();
   return 0;
}
 
程序运行结果:
a=1
a=1
a=1
 
b=1
b=2
b=3
阅读(2093) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~