首页 > 编程语言 > 详细

【学习笔记】【C语言】结构体的嵌套

时间:2015-06-29 22:07:08      阅读:206      评论:0      收藏:0      [点我收藏+]
 1 #include <stdio.h>
 2 
 3 int main()
 4 {
 5     struct Date
 6     {
 7         int year;
 8         int month;
 9         int day;
10     };
11     
12     
13     // 类型
14     struct Student
15     {
16         int no; // 学号
17         
18         struct Date birthday; // 生日
19         
20         struct Date ruxueDate; // 入学日期
21         
22         // 这种写法是错误的
23         //struct Student stu;
24     };
25     
26     
27     struct Student stu = {1, {2000, 9, 10}, {2012, 9, 10}};
28     
29     printf("year=%d,month=%d,day=%d\n", stu.birthday.year, stu.birthday.month, stu.birthday.day);
30     
31     
32     
33     
34     
35     return 0;
36 }

 

 

【学习笔记】【C语言】结构体的嵌套

原文:http://www.cnblogs.com/dssf/p/4608851.html

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