结构指针数组问题

时间:2020-06-04 16:14:43

标签: c struct

typedef struct ListNode *Position;
typedef struct Position List; 
typedef struct HashTbl *HashTable;

struct ListNode{
    int Element;
};

struct HashTbl{
    int TableSize;
    List* TheLists;
};

int main(){
    int size = 5;
    HashTable hashTable = malloc(sizeof(struct HashTbl));
    hashTable->TheLists = (List*)malloc(sizeof(List*)*size);
    //i want to approach Element of ListNode
    for(int i=0 ; i<size ; i++){
        hashTable->TheLists[i] = malloc(sizeof(struct ListNode));
        //at [i] : Subscript of pointer to incomplete type 'List' 
    }
}

如何处理ListNode的Element? 我认为“ TheList”是一个指针数组。所以我尝试分配和处理它。 但是在hashTable-> TheLists ** [** i]中,编译器说

Subscript of pointer to incomplete type 'List'.

我该如何解决?

0 个答案:

没有答案