结构体指针

 1 #include <iostream>
 2 using namespace std;
 3 struct Student
 4     {
 5         string name;
 6         int age;
 7         int score;
 8     };
 9 int main() {
10     Student s = {"张三",18,100};
11     Student *p= &s;
12     cout<<"姓名:"<<p->name<<endl;
13     cout<<"年龄:"<<p->age<<endl;
14     cout<<"分数:"<<p->score<<endl;
15     return 0;
16 }

 

posted @ 2022-03-13 17:46  赵凤武  阅读(24)  评论(0)    收藏  举报