c语言建线性表出错。。。
程序代码:#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<stdlib.h>
struct STU{
char Name[20];
int Age;
int Score;
};
typedef struct STU stu;
struct LIST{
stu S[20];
int Length;
};
typedef struct LIST List;
void init(List* L){
L=(List*)malloc(sizeof(List));
//L->Length=0;
}
void Found_LIST(List L,stu S[]){
int count;
for(count=0;count<L.Length;count++){
L.S[count]=S[count];
}
void Print_List(List L){
printf("Account Name Age Score\n");
int i;
for(i=0;i<L.Length;i++)
printf("%4d%4d%4d%4d",i,L.S[i].Name,L.S[i].Age,L.S[i].Score);
}
void main(void){
List L; stu S[3]; init(L);
L.Length=3;
strcpy(S[1].Name,"TOM");S[1].Age=20;S[1].Score=90;
strcpy(S[2].Name,"Jane");S[2].Age=21;S[2].Score=80;
strcpy(S[3].Name,"Mari");S[3].Age=20;S[3].Score=90;
Found_LIST(L,S[3]);
Print_List(L);
}









