const关键字用法

* 读作 pointer to,从右向左读

<type> * const p   变量p存放在read-only数据段,p为常量指针,p只用于读操作, 告诉编译器,p仅用做右值;

读作:p is const pointer to <type>

 

  const <type> *p   变量p存放在栈区; *p不一定为常量区,但*p只用于读操作,告诉编译器*p仅用作右值;

<type> const *p == const <type> *p

读作:p is pointer to const <type>

附加:

参考链接 :http://blog.csdn.net/luoyeaijiao/article/details/7982385             C中const的实现机制

原文地址:https://www.cnblogs.com/xiaokuang/p/4550147.html