【发布时间】:2016-06-30 13:20:25
【问题描述】:
我目前正在使用不透明指针编写二叉树结构。但是,我对 Valgrind 的写入无效。
Tree.c:
struct node{
int key;
struct node *left, *right, *parent;
};
NODE nodeInit(void)
{
NODE tree = (NODE) malloc(sizeof(NODE));
tree->key = -1;
//Error with the 3 lines below
tree->right = NULL;
tree->left = NULL;
tree->parent = NULL;
return tree;
}
Tree.h:
typedef struct node* NODE;
注意:我不能更改头文件。
【问题讨论】:
标签: c algorithm pointers data-structures tree