const int *p; //const在*前面,表示指针*p不能被赋值,但可以修改指针地址
int *const p; //const在*后面,表示指针不能被修改地址,但可以被赋值
#include <stdio.h>
int main()
{
/* Write C code in this online editor and run it. */
int a=11,b=22;
const int *p1; //const在*前面,表示指针*p1不能被赋值,但可以修改指针地址
p1=&a;
printf(" *p1=%d \n",*p1);
p1=&b;
printf(" *p1=%d \n",*p1);
//*p=33; //此时赋值指针是不被允许的
int *const p2;//const在*后面,表示*p2不能被修改地址,但可以被赋值
//p2=&a; //此时修改指针的地址是不被允许的
*p2=33;
printf(" *p2=%d \n",*p2);
printf("Hello, World! \n");
return 0;
}