“指针常量” 和“常量指针” 很容易理解出问题(至少我是这样滴),感觉还是英文说的比较准确。
一篇讨论const 与指针的英文文章
如果懒得去仔细看英文,这里有个简单总结:
1. “指针常量”
==“指针本身是常量”
=="指针保存的内容不能修改,即只能指向初始化时的变量"
==“constant pointer”
==“The location stored in the pointer cannot change. You cannot change where this pointer points”
example:
char *const myPtr;
2. “常量指针”
=="指向常量的指针”
==“指针本身可以修改,但不能通过该指针修改指向的对象,即(*pointer)是不能修改的”
==“pointer to constant"
=="You cannot use this pointer to change the value being pointed to"
example:
const char* myPtr;
over!