我有一个结构是一个节点,另一个是这些节点的列表。在列表结构,其节点的数组,而是数组,这是一个指针的大小整数指针:如何初始化指针指向C中的指针结构?
typedef struct node {
struct node *next;
MyDef *entry;
} Node;
typedef struct list {
Node **table;
int size;
} List;
List *initialize(void)
{
List *l;
Node **n;
if ((l = (List *)malloc(sizeof(List))) == NULL)
return NULL;
l->size = 11;
/* I think this is correctly allocating the memory for this 'array' of nodes */
if ((n = (Node **)malloc(l->size * sizeof(Node))) == NULL)
return NULL;
/* Now, how do I set MyDef *entry and Node *next to NULL for each of the 'array'? */
l->table = n;
return l;
}
如何设置MyDef *入境和节点*旁边NULL为每'数组'?
太多星星...你使用'**'作为“2D数组”,而不是用于“简单”元素列表 – pmg 2010-10-26 09:56:43
取自:http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx – 2010-10-26 10:01:23