目录
一.结构体指针
指针可以指向变量,数组,函数。当然也可以指向结构体,指向结构体的指针叫做结构体指针。
二.结构体指针的定义
struct student
{
int num;
char name[50];
float score;
};
struct student stu = {01,"zhangsan",99};
struct student *p = &stu;
三.结构体指针成员访问
1.p->结构体成员;
2.(*p).结构体成员;
四.综合例子
#include <stdio.h>
struct student
{
int num;
char name[50];
float score;
};
int main(void)
{
struct student stu = {01,"zhangsan",99};
struct student *p = &stu;
printf("num is %s\n",p->name);
p->score = 99.9;
printf("scoreis %0.1f\n",(*p).score);
return 0;
}