常量指针与指针常量

#include <stdio.h>
int main() {
char c = '\0';
if (c)
printf("afa");
int x = 1, y = 10;
const int *p2 = &x;
printf("%d\n", *p2);
x = 2;
//*p2 = 3; //常量指针,指向常量的指针,*p2是一个常量,不能修改
printf("%d\n", *p2);
int *const p3 = &x;
// p3 = &y; //指针常量
return 0;
}

image-20210406115550244