1、在c中,定义常量可以使用const和#define

       格式:const   类型名  常量名  =   值

       格式:#define    常量名   值

2、const与类型名的顺序可以互换

3、#define只是负责简单的替换

例子如下:

 

#include <stdio.h>
#define CLASS "zhangzetian"
#define DATE 20130614
#define AA PI*
#define BB 10+student_num


int main(){
const double PI = 3.14;
int const student_num = 40;

printf("PI=%g,student_num=%d\n",PI,student_num);
printf("CLASS=%s,DATE=%d\n",CLASS,DATE);
printf("AA*BB=%g\n",AA BB);//特别要注意这一行输出的结果

return 0;

}


结果如下:

 

常量_#include