gpt4 book ai didi

C: 在 BST 打印输出上解引用指向不完整类型错误的指针

转载 作者:行者123 更新时间:2023-11-30 15:51:55 26 4
gpt4 key购买 nike

我正在尝试打印存储在链表 BST 中的单词。当我尝试打印该单词时,它给出了“取消引用指向不完整类型的指针”错误。

我的打印函数位于 BST 结构的头文件中。在我的主函数中,我可以像这样打印出来,没有问题,但它似乎不想在这个函数中打印。

//linked list struct
struct ll_node
{
char * word;
struct ll_node * next;
};



//BST struct
struct bst_node
{
int occurs;
int diffOccurs;

struct bst_node * left;
struct bst_node * right;

struct ll_node * words;
};



//printout function
void * printTree(struct bst_node * currBST)
{
if(currBST == NULL)
{
return;
}

printf("%s\n", currBST->words->word);

printTree(currBST->left);
printTree(currBST->right);

}

最佳答案

struct bst_nodestruct ll_node 都应该在使用 currBST->words->word 之前定义。 .

关于C: 在 BST 打印输出上解引用指向不完整类型错误的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14791760/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com