const* 与*const

1.指向常量的指针和指针常量

    int a=0;
    const int *const p=&a;
//    *p=2;//error: assignment of read-only location '*(const int*)p'
    int *const p1=&a;
    *p1    =3;//正确

在p的生命中,从左往右的第一个const说明,它不能改变a中的值,第二个const说明它不能指向别的对象。

原文地址:https://www.cnblogs.com/BlueBlueSea/p/13898973.html