#include <stdlib.h> /*使用m a l l o c ( ) 需要* /
struct data / *定义结构体* /
{
int day,month,year;
} ;
struct stu /*定义结构体* /
{
char name[20];
long num;
struct data birthday; /嵌*套的结构体类型成员*/
} ;
main() /*定义m a i n ( ) 函数* /
{
struct stu *student; 定/*义结构体类型指针*/
student=malloc(sizeof(struct stu)); 为/指* 针变量分配安全的地址*/
printf("Input name,number,year,month,day:/n");
scanf("%s",student->name); 输/*入学生姓名、学号、出生年月日*/
scanf("%ld",&student->num);
scanf("%d%d%d",&student->birthday.year,&student->birthday.month,
&student->birthday.day);
printf("/nOutputname,number,year,month,day/n");
/*打印输出各成员项的值*/
printf("%20s%10ld%10d//%d//%d/n",student->name,student->num,
student->birthday.year,student->birthday.month,
student->birthday.day);
}