【发布时间】:2026-02-18 13:50:01
【问题描述】:
我有以下结构:
typedef struct bucket {
char *key;
ENTRY *data;
struct bucket *next;
} bucket;
typedef struct {
size_t size;
bucket **table;
} hash_table;
但我不知道如何为此分配内存。我试过了:
hash_table* ht = malloc(sizeof(hash_table)*101);
为了为 101 个条目创建一个哈希表,但它不起作用!谁能帮我?我真的很感激!
【问题讨论】:
-
为什么是bucket **table,而不是bucket *table?
标签: c memory struct hashtable allocation