首页 > 其他 > 详细

结构体嵌套

时间:2014-11-29 21:24:59      阅读:272      评论:0      收藏:0      [点我收藏+]


#include <stdio.h>

int main()
{
    typedef  struct date{
        int year;
        int mouth;
        int day;
    }Date;
    typedef  struct student{
        int age;
        Date birthday;
        Date inday;
    }Student;
    Student stu ={23,{1991,1,1},{2011,1,1}};
    Student *p;
    p = &stu;
    printf("%d,%d,%d\n",stu.age,stu.birthday.mouth,stu.inday.day);
    printf("%d,%d,%d\n",(*p).birthday.year,(*p).birthday.mouth,(*p).birthday.day);
    printf("%d,%d,%d\n",p->birthday.year,p->birthday.mouth,p->birthday.day);
    
    return 0;
}

结构体嵌套

原文:http://www.cnblogs.com/slios/p/4131822.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!