使用此代码:
#include <stdlib.h>
#include <stdio.h>
int j_btree_create (int fn_initial_nodes);
typedef struct {
int depth;
int value;
void *item;
void *left_pointer;
void *right_pointer;
} j_btree_node_int;
typedef struct {
int nodes;
int available_nodes;
int btree_extension;
} j_btree_descriptor_int;
int j_btree_create (int fn_initial_nodes) {
int *free_btree_node;
int loop_counter;
j_btree_descriptor_int *btree_start;
btree_start = (j_btree_descriptor_int *) malloc (((sizeof(j_btree_node_int) + sizeof(free_btree_node)) * fn_initial_nodes) + sizeof(j_btree_descriptor_int));
(*btree_start).nodes = fn_initial_nodes;
(*btree_start).available_nodes = fn_initial_nodes;
(*btree_start).extension = NULL; */
for (loop_counter = 0; loop_counter < fn_initial_nodes; loop_counter++) {
printf ("loop_test: %d", loop_counter);
}
}
我想要一个指向二叉树描述符之后位置的指针(基本上是 btree_start 的结构)
我可以这样做吗
free_btree_node = btree_start + sizeof(j_btree_descriptor_int);
或者这可能会完全出错?如果是这样,我该怎么做?我将做一些类似于最初填充未使用的二叉树节点表的事情。