gpt4 book ai didi

c++ - 有人可以帮我吗?为什么它不编译?

转载 作者:行者123 更新时间:2023-11-30 21:21:59 25 4
gpt4 key购买 nike

这是一个线程二叉搜索树。你能帮我找出为什么它不能编译吗?

http://codeworldtechnology.wordpress.com/2009/08/27/insertion-deletion-and-traversal-in-fully-in-threaded-binary-search-tree/

最佳答案

错误:

tree.c: In function ‘main’:
tree.c:51: warning: incompatible implicit declaration of built-in function ‘exit’
tree.c:51: error: too few arguments to function ‘exit’
tree.c: In function ‘preorder’:
tree.c:327: warning: comparison between pointer and integer

我可以看到 exit(); 是错误的,请纠正它 exit(0);

第 327 行:if(ptr->right_ptr==link) 是错误的,因为 link 是整数,定义为:

typedef enum { thread,link} boolean;    

其中 right_ptr; 是指针:

struct node
{
struct node *left_ptr;
boolean left;
int info;
boolean right;
struct node *right_ptr;
}*head=NULL

我建议此代码已损坏还有其他许多错误,不要使用它!

;

关于c++ - 有人可以帮我吗?为什么它不编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14276864/

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