我有一個結構是一個節點,另一個是這些節點的列表。在列表結構,其節點的數組,而是數組,這是一個指針的大小整數指針:如何初始化指針指向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