码迷,mamicode.com
首页 > 其他好文 > 详细

结构体嵌套

时间:2014-11-29 21:26:50      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   bs   ef   amp   nbsp   type   return   


#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;
}

结构体嵌套

标签:io   ar   sp   bs   ef   amp   nbsp   type   return   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!