const 修饰变量,这个变量就被称为常变量,不能被修改,但本质上还是变量
const修饰指针变量的时候,如果放在*左边,修饰的是*p,表示指针指向的内容,是不能通过指针来改变的;如果放在*右边,p变量不能动,但是指向的内容可以改变
auto 自动的--每个局部变量都是auto修饰
break
case
char
const
continue
default 默认
do
double
else
enum
extern 申明外部符号
float
for
goto
if
int
long
register 寄存器关键字 register int num = 100; //建议num的值存放在寄存器中
return
short
signed 有符号的 10 -20
sizeof
static 静态的
struct
union 联合体
switch
void 无/空
volatile
while
define include 不是关键字,是预处理指令
typedef 类型重定义
typedef unsigned int u_int;
int main()
{
unsigned int num = 100;
u_int num2 = 100;
return 0;
}
static 静态的
修饰局部变量,改变了局部变量的生命周期(本质上是改变了变量的存储类型)
修饰全局变量:只能在自己的源文件(.c)内部使用(内部链接属性)
修饰函数:只能在自己的源文件内部使用(外部链接属性变成内部链接属性)
1.void test()
{
static int a = 1;
a++;
printf("%d ", a); //结果是2到11
}
int main()
{
int i = 0;
while(i<10)
{
test();
i++;
}
return 0;
}
声明外部函数
extern int add(int ,int );