创建线性表并插入数值的时候总是失败,请大神指点

#include
#include
#include
#include
#define ok 1
#define error 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define True 1
#define false 0

typedef int Status;

typedef int ElemType;

typedef int ElemType;

typedef struct{
ElemType *elem;
int length;
int Listsize;
}List;

Status InitList(List &L,int n)//构建线性表
{
L.elem=(ElemType*) malloc(sizeof(ElemType)*LIST_INIT_SIZE); if ( !L.elem)exit(1);
L.length=0;
L.Listsize=LIST_INIT_SIZE;

printf("请输入数字:");
for (int i=0;i<n;i++)  
{ 
  scanf("%d",L.elem[i]);
  ++L.length; 


        if(L.length>=L.Listsize)  

        {  

        ElemType *newbase=(ElemType*)realloc(L.elem,(L.Listsize+LISTINCREMENT)*sizeof(ElemType));  

            if(!newbase)  

                exit(0);  

            L.elem=newbase;  

            L.Listsize+=LISTINCREMENT;  

        }  
    }
printf("初始化一个线性表\n");

return ok; 

}图片说明

main函数在哪里,L本身分配内存了么?

建议看看数据结构这本书