#include<stdio.h>
typedef struct date
{
int year;
int month;
int day;
}DATE;
typedef struct student
{
long sutdentID; //long的取值范围是-21,4748,3648 to 2147483647.
char studentName[13]; //尝试存入4开头的10位学号导致了越界,谨记!
char studentSex;
DATE birthday;
int score[4];
}STUDENT;
int main()
{
int i;
STUDENT stu1,stu2;
printf("Input a record:\n");
scanf("%ld",&stu1.sutdentID);
scanf("%s",stu1.studentName); //存入姓名不用写&取地址符
scanf(" %c",&stu1.studentSex); //c前面有一个空格,用以防止缓冲区的回车存入变量
scanf("%d",&stu1.birthday.year);
scanf("%d",&stu1.birthday.month);
scanf("%d",&stu1.birthday.day);
for(i=0;i<4;i++)
{
scanf("%d",&stu1.score[i]);
}
stu2 = stu1;
printf("&stu2=%p\n",stu2);
printf("%11ld%13s%3c%6d/%02d/%02d%4d%4d%4d%4d\n",
stu2.sutdentID,stu2.studentName,stu2.studentSex,stu2.birthday.year,stu2.birthday.month,stu2.birthday.day,
stu2.score[0],stu2.score[1],stu2.score[2],stu2.score[3]);
return 0;
}