1、打开啊哈c编译器
2、struct student{ int score; char name[128];};//先定义一个结构体
3、struct student stul; stul.score = 100; strcpy(stul.name,"张三"); print熠硒勘唏f("名字:%s,分数:%d\n",stul.name,stul.score);
4、struct student *p;//愍荪土榷野指针 //p.score = 100;//如果用结构体指针,就不能用点运算访问结构体中的变量,要用-> //指针要注意是否是野指针或者NULL p = (struct student *)malloc(sizeof(struct student));//开辟空间 memset(p,'\0',128);
5、p->score = 98; strcpy(p->name,"李四"); printf("名字:%s,分数:%d\n",p->name,p->score);
6、printf("地址是:%p\n",p++); printf("加后地址是:%p\n",p);
7、运行程序