const char* a 与 char* const b 的区别

const char* a表示a是指向一个字符串常量的指针,也就是说a所指向的内容是不能改变的(但是可以改变a所指向的地址),例如:

*a='A';

是不允许的,而

a=newstring;

是允许的。

char* const b表示b是一个常指针,也就是说b必须始终指向同一个地址(但是可以改变b所指向的元素的值),例如:

b=newstring;

是不允许的,而

*b='B';

是允许的。

posted @ 2016-09-11 16:51  BelFuture  阅读(1296)  评论(0编辑  收藏  举报
The horizon of life is broadened chiefly by the enlargement of the heart.