const int * p1; in this case, the format p1 its space can be change.
int const * p2; in this case, the format p2 its pointer can not be change.
for example.
p1 =&i;
p2 =&j;
this case, p1=&l;also can equal to &k;
p2=&j;
p2 only equal to &j;
this pointer can not be changed.
void fun(const int i)
{
i++;(running wrong report)
}
void fun(const int *p)
{
(*p)++;(running wrong report)
}
const int i =0;
also equal to int const i =0;
const its usage
最新推荐文章于 2024-10-09 10:04:07 发布
博客介绍了C语言中const修饰指针和变量的情况。如const int * p1指针指向的空间可改变,int const * p2指针本身不能改变;还提到const修饰函数参数时,参数值不能修改,以及const修饰变量的两种等价写法。
830

被折叠的 条评论
为什么被折叠?



