c 常量 const
1、const定义的值是不可以改变的,类似于java的final
#include "stdio.h" main(){ int a=3; int b=6; int c=9; int const *p=&a; int *const p1=&b; int const *const p2=&c; p=&b; //*p=4;/** 报错,error: assignment of read-only location ‘*p’ **/ a=4;// p1=&a;/** 报错,error: assignment of read-only location ‘p1’ **/ *p1=5; b = 7; p2=&c;/** 报错,error: assignment of read-only location ‘p2’ **/ *p2=8;/** 报错,error: assignment of read-only location ‘*p2’ **/ c = 3;}