结构体指针
作者:互联网
int main() {//主函数返回值为整型
struct student
{
string name;
int age;
int score;
};
//2.创建结构体数组
struct student stuarray[3] =
{
{"张三",18,100},
{"李四",20,88},
{"王五",50,67}
};
//3.通过指针指向结构体变量
student* p = &stuarray[3];
//4.通过指针访问结构体变量中的数据
//使用->访问
cout << "姓名:" << p->name << "年龄:" << p->age << "分数:" << p->score << endl;
system("pause");//暂停系统命令
return 0;//退出程序
}
标签:struct,int,score,student,指针,stuarray,结构 来源: https://blog.csdn.net/weixin_45149964/article/details/119061344