1

这段代码:

#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));
    printf ("btree_start: " . btree_start);
    /* *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:" . loop_counter);
    }
}

产生此错误:

/home/jamie/aws/btree_int.c||在函数“j_btree_create”中:| /home/jamie/aws/btree_int.c|28|错误:在不是结构或联合的东西中请求成员“btree_start”| /home/jamie/aws/btree_int.c|33|错误:在不是结构或联合的东西中请求成员“loop_counter”| ||=== 构建完成:2 个错误,0 个警告 ===|

使用 CodeBlocks 编译时。我还没有设法找到我的问题的确切答案(我看过),有人知道我做错了什么吗?鉴于我对 C 相当陌生,可能不止一件事。

4

1 回答 1

0
printf ("btree_start: " . btree_start);

这不是事情是如何完成的c。没有.连接运算符,也没有连接字符串(指向字符的指针)和指向结构的指针。如果你想打印出指针,它是

printf("btree_start: %p\n",btree_start);

对于循环计数器,它是

printf("loop_test: %d",loop_counter);
于 2012-10-06T21:16:47.427 回答