I'm trying to create a new node for a binary tree, and I'm getting errors when I try to make an assignment to ->left and ->right.
我正在尝试为二叉树创建一个新节点,当我尝试将任务分配给 - > left和 - >时,我遇到了错误。
typedef struct bin_node_t {
data_t data;
bst_key_t key;
struct bin_node *left;
struct bin_node *right;
} bin_node;
Is my struct definition for bin_node.
是我对bin_node的结构定义。
Here are the variables I'm using:
以下是我正在使用的变量:
bin_node *new;
bin_node *node_array[256];
Here's my variable assignments:
这是我的变量赋值:
/* ... code to initialize node_array ... */
new = (bin_node *)malloc(sizeof(bin_node));
and here's where I'm gettin an error:
而这里是我遇到错误的地方:
new->right = node_array[i+1];
new->left = node_array[i];
and here is the compiler warning I'm getting:
这是我得到的编译器警告:
huffman.c:99: warning: assignment from incompatible pointer type
huffman.c:100: warning: assignment from incompatible pointer type
My full code is available at:
我的完整代码位于:
1 个解决方案
#1
5
There's no struct bin_node
in your code. Change struct bin_node *left
to:
您的代码中没有struct bin_node。将struct bin_node *更改为:
struct bin_node_t *left;
^^^
#1
5
There's no struct bin_node
in your code. Change struct bin_node *left
to:
您的代码中没有struct bin_node。将struct bin_node *更改为:
struct bin_node_t *left;
^^^