wufengv5

static

static变量

C语言中static的用法static变量只能初始化一次

在函数内部定义的static变量,

在函数调用过程中,能够保存值,意思就是下次调用函数,这个函数里的这个变量有值,不能被再次初始化

#include<stdio.h>
void a()
{
    static int n = 5;
    printf("%d\n",n);
    n++;
}

void main()
{
    int i;
    for(i=0; i<5; i++)
        a();
}

输出结果如下:

static函数

 

extern

 

const

 

分类:

技术点:

相关文章:

  • 2021-11-23
  • 2021-11-28
  • 2021-11-28
  • 2021-07-25
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-05-14
  • 2021-12-09
  • 2021-11-29
  • 2021-11-29
  • 2021-11-28
  • 2021-11-28
  • 2021-12-09
相关资源
相似解决方案