#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct student
{
char name[8];
int age;
struct student*kd;
};
void main()
{
struct student *help,*header=NULL;//malloc功能是动态开辟连续的内存空间
struct student p_current=(struct student)malloc(sizeof(struct student));
header=p_current;//header只是用一次 用来放张三的地址
help=p_current;//help的地址现在是101
strcpy(p_current->name ,“张三”);
p_current->age=19;
p_current=(struct student*)malloc(sizeof(struct student));
strcpy(p_current->name ,"李四");
p_current->age=20;
help->kd =p_current;//张三的口袋放李四的坐标
help=p_current;//help的地址变成了201
p_current=(struct student*)malloc(sizeof(struct student));
strcpy(p_current->name ,"王五");
p_current->age=21;
help->kd =p_current;//李四的口袋放王五的坐标
p_current->kd =NULL;//王五的口袋里现在没有地址
puts("姓名 年龄");
while(header!=0)
{
printf("%s %d\n",header->name ,header->age );
header=header->kd ;
}
}