There's at least a few things that my compiler gakked on....
My comments are in red in the code block below.... Just a
couple of pointers (no pun intended) to get you going in the
right direction.....
Code:
#include <stdio.h>
#include <stdlib.h>
#define BRANCHES 3
typedef struct node
{
struct node *branches[ BRANCHES ];
struct node *value;
}; /* My compiler says: "
useless keyword or type name in empty
declaration." I think you forgot "node" here
between the closing brace and semilcolon */
void main()
{ struct node *root = 0;
struct node **leaf;
if( *leaf == 0 )
{
*leaf = malloc( sizeof( struct node ) );
/* You've got some precedence issues. For starters, it should be
(*leaf)->branches[0]->value
But, even with that, it still won't compile. You've declared
value as a pointer to struct node, and you're trying to set it to an
integer value here.
My compiler says:
assignment makes integer from pointer without a cast
And THAT will usually cause a seg fault when it is run.
I'm not sure if you want value to be an int or not, but it
does not seem that you'd want it to be a pointer to another
struct node.
*/
*leaf->branches[0]->value = 2;
*leaf->branches[1]->value = 3;
*leaf->branches[2]->value = 4;
}
}
[/QUOTE]