应用结构体完成结构体的输出
例题7.1 声明学生结构体Student
定义两个结构体变量student1和student2
成员包括学号 姓名 性别 出生日期 成绩
学生1初始化
把学生1复制给学生2
输出学生2
#include<iostream> #include <string.h> using namespace std; struct date{ int year; int month; int day; }; struct student{ int num; string name; date jibenn; char sex; float score;} student1={164643131,"yukino",1997,4,84,'girl',85},student2; int main(){ student2=student1; cout<<student2.num<<endl; cout<<student2.name<<endl; cout<<student2.jibenn.year<<endl; cout<<student2.jibenn.month<<endl; cout<<student2.jibenn.day<<endl; cout<<student2.sex<<endl; cout<<student2.score<<endl; }