OC static 和变量

 

 

#include <stdio.h>
// 如果在不同源文件出现了同名的内部变量,那么这些变量将互不干扰
static int b;

// 用static修饰的全部变量,可以称为内部变量
static int a;

void testA() {
    printf("one.c中的a=%d\n", a);
}

 

  调用:

static int b;

void testA();

extern int a;

int main(int argc, const char * argv[])
{
    a = 10;
    
    testA();
    return 0;
}

int a;

 

posted on 2017-05-24 16:40  守望星空  阅读(146)  评论(0编辑  收藏  举报

导航