Arrays 在二维数组中存储链接列表头

Arrays 在二维数组中存储链接列表头,arrays,pointers,struct,linked-list,malloc,Arrays,Pointers,Struct,Linked List,Malloc,我需要创建一个动态大小的2D矩阵,其中矩阵的每个元素都包含一个指向链表头部的指针。我用于定义头部的代码如下所示: struct Node { int data; struct Node *next; }; struct Node *head = NULL; head = (struct Node *)malloc(sizeof(struct Node)); head->data = 1; head->next = NULL; 然后,我使用以下代码创建数组: str

我需要创建一个动态大小的2D矩阵,其中矩阵的每个元素都包含一个指向链表头部的指针。我用于定义头部的代码如下所示:

struct Node
{
    int data;
    struct Node *next;
};
struct Node *head = NULL;
head = (struct Node *)malloc(sizeof(struct Node)); 
head->data = 1;
head->next = NULL;
然后,我使用以下代码创建数组:

struct Node **array = (struct Node **)malloc(Nx * Ny * sizeof(struct Node *));
for(i = 0; i < Nx*Ny; i++)
    array[i] = head;
结构节点**数组=(结构节点**)malloc(Nx*Ny*sizeof(结构节点*); 对于(i=0;i 但我有错。
提前谢谢。

Nx和Ny的值是多少?它们相当大~50,000