有人可以帮我这个吗?为什么不编译?

时间:2013-01-11 11:07:44

标签: c++ c debugging

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

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

1 个答案:

答案 0 :(得分:2)

<强>错误:

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  

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