37.const修饰的结构体数组的指针


#include
//结构体传值和地址传值及const修饰的结构体指针变量
struct Student
{
	int age;
	char name[50];
	int score;
 };
struct Student tmp;
struct Student *p1 = &tmp;
p1->age = 18;
p1 = NULL;
//都是可以的


//const修饰的是*,说明指针指向的内存不可以修改 
const struct Student *p1 = &tmp;//等价于struct Student const *p2; 
p2->age = 18;//error
p2 = NULL;//ok 
 //const修饰的是p2,说明指针本身是常量
struct Student * const p2 = &tmp;
p2->age = 18;//ok
p2 = NULL;//error