【发布时间】:2020-08-19 19:38:27
【问题描述】:
我尝试编写哈希表并找到了这个 github 存储库:enter link description here。我很难理解这段代码:
struct entry_s
{
char* key;
char* value;
struct entry_s* next;
};
typedef struct entry_s entry_t;
struct hashtable_s
{
int size;
struct entry_s** table;
};
typedef struct hashtable_s hashtable_t;
我有两个问题:
- 为什么使用
typedef struct entry_s entry_t;而不是
struct entry_s
{
char* key;
char* value;
struct entry_s* next;
}entry_t;
因为如果我使用第二种方式,我会出错。
- 该代码是什么意思:
struct entry_s** table;
我知道这个问题很容易回答,但如果你能帮助我,我会很高兴
【问题讨论】:
-
你应该更好地阅读编译器给出的错误信息,以及更多地了解你正在使用的数据结构类型,有很多资源详细介绍了X的逐步实现。
标签: c pointers data-structures hashtable double-pointer