14-1 C语言中的关键字
关键字:C语言本身内置的
注意:关键字不是自己创建出来的,也不能自己创建
C语言有哪些关键字呢?
auto break case char const continue default do double else enum
extern float for goto if int long register return short signed
sizeof static struct switch typedef union unsigned void volatile while
auto-所有的局部变量都是自动变量,经常被省略
a进入作用域自动创建,出作用域自动销毁:
int main()
{
auto int a = 10; //自动变量,相当于int a = 10
return 0;
}
break/continue-常用于循环语句,在for/while/do while语句里面使用
内置类型关键字-char short int long float double
signed-有符号的
unsigned-无符号的
const-修饰变量,表示常属性(不能够被修改)
case-在switch case分支语句里使用
else-if else分支语句
goto-实现跳转的语句
enum-枚举
struct-结构体
union-联合体(共用体)
extern-声明外部符号
register-寄存器
static-静态的,限制一个变量停在静态区
return-函数返回值
sizeof-计算大小
typedef-类型重命名
void-无(常用于函数的返回类型、函数的参数)
注意:变量命名不能是关键字
14-2 变量的命名
1、有意义
int age;
float salary;
2、名字必须是字母、数字、下划线组成,不能有特殊字符,同时不能以数字开头
3、变量名不能是关键字
后文会详细讲解几个关键字,敬请期待哈哈哈~~~