1.字面常量:直接打出的数字叫字面常量
2.const定义的常变量:const int 中const只是锁定变量不变,但是实质还是变量,只是有了常数属性,例:
const int n=10;
int arr[n]={0}; //创建数组格式,[]中要用常量
而此时数组格式错误证明const定义的量不为常量
3.define定义的常量:
#include<stdio.h>
#define max 10
int main()
{
int arr[max]={0}; //此时数组输出无误,证明define定义的量为标识符常量
return o;
}
4.枚举常量:
#include<stdio.h>
enum sex
{
male,female,secret /枚举常量
}
int main()
{
enum sex s = male;
printf("%d\n",male); //0
printf("%d\n",female); //1
printf("%d\n",secret); //2
return 0;
}
枚举的例子的值自上而下为0,1,2.....n