//_十分感谢_
#include<stdio.h>
#include<stdlib.h>
typedef struct Elemtype
{
int num[20];
int sum[10];
float score;
}Elemtype;
typedef struct Node
{
Elemtype Data;
struct Node* next;
}Node,* LinkList;
LinkList creatList_head(LinkList L) //_头插法_
{
LinkList s;
L=(Node*)malloc(sizeof(Node));
L->next=NULL;
int flag=1;
while(flag)
{
s=(Node*)malloc(sizeof(Node));
printf("\n请输入姓名,学号,成绩\n");
scanf("%c",&(s->Data.num[20]));
scanf("%c",&(s->Data.sum[20]));
scanf("%3.1f",&(s->Data.score));
s->next=L->next;
L->next=s;
printf("是否继续录入:输入1继续,0结束");
scanf("%d",&flag);
}
return L;
}
void printList(LinkList L) //_输出_
{
LinkList p;
p=L->next;
while(p!=NULL)
{
printf("%d",p->Data.num);
printf("%d",p->Data.sum);
printf("%d",p->Data.score);
printf("\n");
p=p->next;
}
}
int main()
{
LinkList L;
printf("请输入信息!");
L=creatList_head(L);
printList(L);
return 0;
}
把next定义前的struct去掉吧
typedef struct Node
{
Elemtype Data;
struct Node* next;
}Node,* LinkList;
typedef struct Elemtype
{
char num[20];
char sum[20];//名字为什么叫做sum而不是name
float score;
}Elemtype;
scanf("%s",s->Data.num);
scanf("%s",s->Data.sum);
printf("%s",p->Data.num);
printf("%s",p->Data.sum);