#include<stdio.h>intmain(){
//const常属性//const常量的属性,变量num前面加了const之后就不能变了 const修饰的常量变量//这里的num还是变量只是具有了常量的属性//中国人拿到了美国国籍,但是本质上还是中国人constint num =5;printf("%d\n",num);
num =8;printf("%d\n",num);return0;
标识符常量
#include<stdio.h>#defineMAX10//define定义的标识符常量intmain(){
int arr[MAX]={
0};//标识符define 定义的常量可以存放在数组里printf("%d\n", MAX);return0;
枚举常量
//枚举常量//枚举一一列举出来就是枚举//性别-男,女,其他//三原色-红,黄,蓝//星期1,2,3,4,5,6,7//枚举关键字--enum#include<stdio.h>enumSex//Sex性别{
MALE,//男
FEMALE,//女
SECRET //其他};//MALE , FEMALE ,SECRET 这些就是枚举常量//这些枚举常量是有值的,而且不能改变,intmain(){
enumSex s = MALE;//枚举的用法printf("%d\n",MALE);//打印值是0printf("%d\n",FEMALE);//打印值是1printf("%d\n",SECRET);//打印值是2return0;}#include<stdio.h>enumColor{
RED,
YELLOW,
BLUE
};intmain(){
enumColor color = BLUE;//枚举的用法return0;}