[b][red]This message was edited by chtexlion at 2004-7-31 9:42:4[/red][/b][hr]
I wrote a Binary tree program and it works..I need to read in a second file and at the same time search the tree for any words that match in the tree and then print the matched words..
Here is the function:
[code]
T* find(T stuff)
{
if(n->data==stuff)
cout<<stuff<<" ";
if(stuff<n->data && n->left != NULL)
return find(stuff);
else if(stuff>n->data&&n->right!=NULL)
return find(stuff);
return NULL;
}
//Here is thepart in main I am asking about:
infile.open("a:Ithillian.txt");
string s;
while(!infile.eof())
{
infile>>s;
tree.find(s)
}
[/code]
Comments
[code]
tree.find(s);
[/code]
: I wrote a Binary tree program and it works..I need to read in a second file and at the same time search the tree for any words that match in the tree and then print the matched words..
:
: Here is the function:
: [code]
: T* find(T stuff, node*n=root)
: {
: if(n->data==stuff)
: return n;
: if(stuffdata && n->left != NULL)
: return find(stuff,n->left);
: else if(stuff>n->data&&n->right!=NULL)
: return find(stuff,n->right);
: return NULL;
: }
:
: //Here is thepart in main I am asking about:
:
: infile.open("a:Ithillian.txt");
: string s;
: while(!infile.eof())
:
: {
: infile>>s;
: tree.find(s,[red]???[/red]);//[green]What do I need to send
: } //as a parameter since it is a
: //node* in the function?
:
?? What should I do about that?
I wrote a Binary tree program and it works..I need to read in a second file and at the same time search the tree for any words that match in the tree and then print the matched words..
:
: Here is the function:
: [code]
: T* find(T stuff, node*n=root)
: {
: if(n->data==stuff)
: return n;
: if(stuffdata && n->left != NULL)
: return find(stuff,n->left);
: else if(stuff>n->data&&n->right!=NULL)
: return find(stuff,n->right);
: return NULL;
: }
:
: //Here is thepart in main I am asking about:
:
: infile.open("a:Ithillian.txt");
: string s;
: while(!infile.eof())
:
: {
: infile>>s;
: tree.find(s,[red]???[/red]);//[green]What do I need to send
: } //as a parameter since it is a
: //node* in the function?
: