C语言的关键字 auto typedef static

关键字

1.c语言提供的,不能自己创建关键字

2.变量名不能是关键字

#include <stdio.h>
//auto 是自动变量

int mian()

{

    {

     int a = 10;   //自动创建,自动销毁的 - 自动变量//auto 省略掉了 还有其他用法

    }

return 0;

}

#include <stdio.h>
int main()

{

register int num = 100;//建议num 被 register修饰了 num的值存放在寄存器中

return 0;

}

 

而头文件 include define 都不是关键字 是预处理指令

typedef类型重定义

#include <stdio.h>
//typedef使unsigned iint = u_int

typedef unsigned int u_int;

int mian()

{

unsigned int num = 100;// unsigned int num= u_int num = 100;

return 0;

}

static - 静态

1. static修饰局部变量 改变了局部变量的生命周期参考 下面函数

2. static修饰全部变量

3. static修饰函数

#include <stdio.h>
void test ()

{

int a = 1;//这里的a是局部变量  出范围就销毁 10个2


/*static int a = 1;*/
//这里的a被static修饰变成全局变量 所以2没有销毁 一直加一 2 3 4 。。。11

a++;

printf("%d ", a);//10个2

}

int main()

{

int i = 0;

while (i < 10)

{

test();

i++;

}

return 0;

}              

     

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值