#include <stdio.h> int main() { /*************************************************** *结构体嵌套:结构体里面包含结构体 * *注意:被包含的结构体要先定义,结构体不能包含自己 ****************************************************/ struct Date { int year; int month; int day; }; struct Student { int no; struct Date birthday; }; struct Student student = { 1, {1989, 2, 4} }; printf("no = %d, birthday = %d年%d月%d日 ", student.no, student.birthday.year, student.birthday.month, student.birthday.day); return 0; }
no = 1, birthday = 1989年2月4日