#include
#include<string.h>
#include <stdio.h>
using namespace std;
struct student {
string name;
int age;
string sex;
};
void byValue(struct student s1)
{
cout << "通过传值输出结构体中的数据:" << endl;
cout << "姓名为:" << s1.name
<< "性别为:" << s1.sex << "年龄为" << s1.age << endl;
}
void byAddress(struct student *p)
{
cout << “通过传地址输出结构体中的数据:” << endl;
cout << “姓名为:” <name
<< “性别为:” << p->sex << “年龄为” << p->age<< endl;
}
int main()
{
struct student s1;
s1 = { "张三",12,"男" };
// 传值输入结构体中的数据
byValue(s1);
// 传首地址输入结构体中的数据
byAddress(&s1);
return 0;
}