-
const
-
extern
-
static
1.const:
使用格式:
const int a =10;
作用:
const修饰的变量存在flash里,变量的值不允许改变
使用:
当存放大量数据并且不需要修改的时候可以使用const修饰
比如:
图片信息
2.extern: //外部的
使用格式:
extern int a;
作用:
extern修饰的变量可以跨文件使用
3.static: //静态的
作用:
修饰函数:函数只能在当前.c文件中使用——起到隔绝,函数定义相同互不影响
修饰变量:此局部变量放在静态区,函数结束时,变量不释放。*程序结束时才释放
例:
void main(void)
{
mm(); //a=1 b=1
mm(); //a=1 b=2
mm(); //a=1 b=3
}
void mm(void)
{
int a;
static int a = 0;
a++;
b++;
printf("a:%d",a);
printf("b:%d",b);
}