#include <iostream> using namespace std; //定义学生结构体 struct student { //姓名 string name; //年龄 int age; //分数 int score; }; //打印学生函数 //1.值传递 void printstudent(student s) { cout << "名字" << s.name << "年龄" << s.age << "分数" << s.score << endl; } //2.地址传递 void printstudent2(student* p) { cout << "名字" << p->name << "年龄" << p->age << "分数" << p->score << endl; } int main() { //结构体做函数参数 //将学生传入到一个参数中,打印学生身上的所以信息 //创建结构体变量 student s; s.name = "张三"; s.age = 18; s.score = 100; printstudent(s); printstudent2(&s); system("pause"); return 0; }