#include <malloc.h>
#include <stdio.h>
#define MaxSize 50
typedef int ElemType;
typedef struct
{ ElemType data[MaxSize];
int length;
}SqList;
void InitLIst(SqList *L)
{L=(SqList*)malloc(sizeof(SqList));
L->length=0;
}
void CreateList(SqList L,ElemType a[],int n)
{
printf("%d",a[0]);
int i=0,k=0;
L=(SqList)malloc(sizeof(SqList));
while(i<n)
{ L->data[k]=a[i];
k++;i++;
}
L->length=k;
}
void DispList(SqList *L)
{ for(int i=0;ilength;i++)
printf("%d",L->data[i]);
printf("已全部输出\n");
}
int main()
{
SqList L;
ElemType a[10]={0,1,2,3,4,5,6,7,8,9};
InitLIst(&L);
CreateList(&L,a, 10);
DispList(&L);
}
为什么输出结果是这样