/*个人基本情况*/? #include<stdio.h> #include<string.h>? struct date { ?? ?int year,month,day; }birthday; ?//"birthday"可有可无? struct person { ?? ?char name[20]; ?? ?char sex[20]; ?? ?struct date birthday; }man; int main() { ?? ?strcpy(man.name,"small陀螺");? ?? ?strcpy(man.sex,"男");? ?? ?man.birthday.year=2000; ?? ?man.birthday.month=12; ?? ?man.birthday.day=9;? ?? ?/*上面五行等价于 ? struct person man = {"small陀螺","男",{2000,12,9}};*/ ?? ?printf("名字:%s\n性别:%s\n",man.name,man.sex); ?? ?printf("生日为:%d年%d月%d日",man.birthday.year,man.birthday.month,man.birthday.day); ?? ?return 0; }
|