#include<iostream>
#include<string>
using namespace std;
//定义结构体
struct Student {
string name;
int age;
int score;
};
int main() {
Student s1 = { "张三", 12, 60 };
Student* p1 = &s1;
//使用指针访问结构体中的变量时,用->
cout << p1->name << " " << p1->age << " " << p1->score << endl;
system("pause");
return 0;
}
结构体指针
最新推荐文章于 2024-05-29 12:49:34 发布