2013-01-11 26 views
-4

這是一個線程化的二叉搜索樹。你能幫我找出它爲什麼不能編譯?clould有人幫我這個嗎?爲什麼不編譯?

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

+0

向我們展示您的錯誤,這樣我們實際上可以幫助您 – Minion91

+0

顯示也有錯誤的代碼段,這是大量代碼,人們不一定有時間看... – Nim

+1

(a)發佈代碼,(b)自己編譯它[你做了],(c)發佈錯誤。 – Nawaz

回答

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 

我建議這個代碼是還有其他很多bug,不使用它!

;

+0

是的,你打我吧 - 雖然它實際上第一次編譯我在一個空白的Visual Studio項目中標記相同的錯誤作爲警告(其他警告是關於缺少返回類型和缺少前向聲明等)。基本上這個代碼是垃圾。 – TheMathemagician

+0

以及我基本上需要一個線程二叉搜索樹的c或C++源代碼。我在這裏解決了這個問題,因爲我無法得到它的工作。有什麼建議麼? – user1969713

+0

@TheMathemagician謝謝!..是的代碼是沒有用的.. –

相關問題