为什么函数只能执行一次

下面的代码中为什么InitLis()只能执行InitList(A)而下面的就不能执行了,该怎么解决?

img

img

代码:

//
// Created by 86159 on 2022/4/16.
//

#include <stdio.h>
#include <malloc.h>

#define Elemtype int
#define ok 1   //返回状态   成功
#define ERROR 0  //失败
#define MAXSIZE 100

//0.申明存储结构
typedef struct{
    Elemtype *Elem;//指向数组指针
    Elemtype length;//当前数组长度
    Elemtype ListSize;//当前数组容量
}SqList;

//1.创建顺序表(初始化)
void InitList(SqList *L){
    //申明数组空间
    L->Elem = (Elemtype*)malloc(MAXSIZE*sizeof(SqList));
    L->length = 0;
    L->ListSize = MAXSIZE;
    printf("kkkkkk\n");
}
//入表
Elemtype Ecterfrom(SqList *L,int l){
    if(L->length == L->ListSize){
        printf("表满");
    }else{
        *(L->Elem + L->length) = l;
       return ++L->length;
    }

}
//合并
SqList Merge(SqList *A,SqList *B,SqList *C){
    //两个数组中有空
    if(A->length == 0){
        C->Elem = B ->Elem;
        C->length = B->length;
        return *C;
    }
    if(B->length == 0){
        C->Elem = A->Elem;
        C->length = A->length;
        return *C;
    }
    //两个数组没有空
    int i,j,k;
    for(i = 0,j = 0,k = 0;i < A->length;i++){
        if(*(A->Elem + i) < *(B->Elem + j)){
            *(C->Elem + k++) = *(A->Elem + i);
        }else{
            *(C->Elem + k++) = *(B->Elem + j++);
        }
        //若A,B两数组中有一数组已全部移入C则执行以下判断
        if(i == A->length - 1 || j < B->length - 1){
            while(j < B->length){
                *(C->Elem + k++) = *(B->Elem + j++);
            }
        }
        if(i == B->length - 1 || j < A->length - 1){
            while(i < A->length){
                *(C->Elem + k++) = *(A->Elem + i++);
            }
        }

    }
    return *C;

}
int main(){
    SqList *A;
    SqList *B;
    SqList *C;
    printf("llllll\n");
    InitList(A);
    printf("llllll\n");
    InitList(B);
    printf("llllll\n");
    InitList(C);
    printf("llllll\n");
    C->Elem = (Elemtype*)malloc(2*MAXSIZE*sizeof(SqList));
    int i,a;
    for(i = 0,a = 0;i < MAXSIZE;i++){
        scanf("请输入A的元素%d\n",&a);
        Ecterfrom(A,a);
    }
    for(i = 0,a = 0;i < MAXSIZE;i++){
        scanf("请输入A的元素%d\n",&a);
        Ecterfrom(A,a);
    }
    i = 0;
    while(i < MAXSIZE){
        printf("元素A%d元素B%d",*(A->Elem + i),*(B->Elem + i));
        i++;
    }
    i = 0;
    while(i < 2*MAXSIZE){
        printf("元素C%d",*(C->Elem + i));
        i++;
    }
}


输出结果:

llllll
kkkkkk
llllll