代码
#include <iostream>
using namespace std;
#include <string>//结构体指针
//定义结构体
struct Student
{ string name;//姓名 int age;//年龄 int score;//分数
};int main()
{//1、创建结构体变量struct Student s = { "张三",18,100 };//2、通过指针指向结构体变量struct Student * p = &s;//3、通过指针访问结构体变量中的数据cout << " 姓名:" << p->name << " 年龄:" << p->age << " 分数:" << p->score << endl;return 0;
}