#include <stdio.h>
#include <stdlib.h>
struct STU
{
char name[5];
int age;
struct STU *next;
};
int main()
{
struct STU a,b,c;
a.next=&b;
b.next=&c;
c.next=NULL;
struct STU *phead;
struct STU *p;
phead=&a;
p=phead;
printf("输入第一个人姓名 年龄");
scanf("%s %d",&a.name,&a.age);
printf("输入第二个人姓名 年龄");
scanf("%s %d",&b.name,&b.age);
printf("输入第三个人姓名 年龄");
scanf("%s %d",&c.name,&c.age);
while(p!=NULL)
{
printf("%s %d \n",p->name,p->age);
p=p->next;
}
}
#include <stdlib.h>
struct STU
{
char name[5];
int age;
struct STU *next;
};
int main()
{
struct STU a,b,c;
a.next=&b;
b.next=&c;
c.next=NULL;
struct STU *phead;
struct STU *p;
phead=&a;
p=phead;
printf("输入第一个人姓名 年龄");
scanf("%s %d",&a.name,&a.age);
printf("输入第二个人姓名 年龄");
scanf("%s %d",&b.name,&b.age);
printf("输入第三个人姓名 年龄");
scanf("%s %d",&c.name,&c.age);
while(p!=NULL)
{
printf("%s %d \n",p->name,p->age);
p=p->next;
}
}