我正在尝试创建一个可以保存通用值的结构。下面的代码有效,但我收到关于从指针转换为整数的编译器警告。这是在 64 位系统上。
struct node
{
    void *key;
    void *value;
};
void insert(struct node *ht, void *key, void *value)
{
    ht->key = key;
    ht->value = value;
    return;
}
int main()
{
    struct node *t = (struct node *)malloc(sizeof(struct node));
    insert(t, (void *)3, (void *)5);
    printf("[%d]->[%d]\n", (int)t->key,(int)t->value);
    free(t);
    return 0;
}
我什至不确定这是否是正确的方法。我有点破解它。请让我知道是否有适当的方法来做到这一点。