> For the complete documentation index, see [llms.txt](https://peiyafei.gitbook.io/c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://peiyafei.gitbook.io/c/1.8-jie-gou-ti/8.4-jie-gou-ti-zhi-zhen.md).

# 8.4 结构体指针

**作用：**&#x901A;过指针访问结构体中的成员

* 利用操作符 `->`可以通过结构体指针访问结构体属性

**示例：**

```
//结构体定义
struct student
{
	//成员列表
	string name;  //姓名
	int age;      //年龄
	int score;    //分数
};


int main() {
	
	struct student stu = { "张三",18,100, };
	
	struct student * p = &stu;
	
	p->score = 80; //指针通过 -> 操作符可以访问成员

	cout << "姓名：" << p->name << " 年龄：" << p->age << " 分数：" << p->score << endl;
	
	system("pause");

	return 0;
}
```

{% hint style="info" %}
总结：结构体指针可以通过 -> 操作符 来访问结构体中的成员
{% endhint %}
