应用结构体完成结构体的输出
例题7.1 声明学生结构体Student
定义两个结构体变量student1和student2
成员包括学号 姓名 性别 出生日期 成绩
学生1初始化
把学生1复制给学生2
输出学生2
#include <iostream> #include <string.h> using namespace std; struct Date{ int month; int day; int year; }; struct Student{ int num; string name; char sex; int age; Date birthday; float score; string addr; }student1={10001,"zhangsan",'m',23,12,12,2017,100,"北京市昌平区马池口吉利大学"},student2; int main(){ student2=student1; cout<<student2.num<<endl; cout<<student2.name<<endl; cout<<student2.sex<<endl; cout<<student2.age<<endl; cout<<student2.birthday.year<<'/'<<student2.birthday.month<<'/'<<student2.birthday.day<<endl; cout<<student2.score<<endl; cout<<student2.addr<<endl; return 0; }
Never waste time any more, Never old man be a yong man