输入后,输不出结果怎么回事?
#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
xt;char name;
int age;
struct Node* ne
}Node,*LinkList;
LinkList date(int n)
{
LinkList p, r=NULL, list=NULL;
char num1;
int num2;
for (int i = 0; i <n; i++)
{
printf("请输入姓名:");
scanf("%s", &num1);
printf("请输入年龄:");
scanf("%d",&num2);
p = (LinkList)malloc(sizeof(Node));
p->name = num1;
p->age = num2;
p->next = NULL;
if (list == NULL)
{
list = p;
}
else
r->next = p;
r = p;
}
return (list);
}
int main()
{
int a;
Node* q;
printf("请输入学生个数:");
scanf("%d", &a);
q = date(a);
printf("姓名 年龄\n");
while(q!=NULL)
{
printf("%s",q->name);
printf("%-4d",q->age);
q=q->next;
printf("\n");
}
return 0;