Click to See Complete Forum and Search --> : Tree Traversal in C help please


RAGEAngel9
11-19-2001, 12:17 AM
Hey guys I'm trying build a tree traversal function and i'm kind of stuck.
I'm supposed to take a tree, a enum that has the method of traversal, and a pointer to a function that will do something with each node.
Well
I've tried building the function with 4 if statements, one for each method.
I think the problem is with my ifs

void Tree_Traverse(Tree *List , Tree_Traverse_Method Direction , void
(*Func)(Person *) )

if ( Direction == LNR )
{
Blah blah
}

does this look right?

RAGEAngel9
11-19-2001, 12:37 AM
ok ignore most of what i worte.
I would just like to know i'f I'm correctly comparing my enums.


typedef enum {
LNR,
RNL,
NLR,
LRN
} Tree_Traverse_Method;

void Tree_Traverse(Tree *List , Tree_Traverse_Method Direction , void
(*Func)(Person *) )
{

if( Direction == LNR)
{
stuff
}
}

is this correct?
Thankx

Niminator
11-19-2001, 04:30 AM
It should work...


Haven't used enum much, but it looks correct.

[ 19 November 2001: Message edited by: Niminator ]