Maximus Programus Maximus Programus - 7 months ago 39
C Question

Is it possible to make an array of pointers to struct (node)?

So I'm trying to make a prefix tree, but I'm not sure if this would cause some logical error of some sort?

typedef struct TreeTag
char letter;
struct TreeTag *links[26]; /* Is this advisable? */
int fullword;
int linknum;


Yes, array of pointers to struct node is allowed

If you do this:

struct node * p; //it's allowed

so there is no problem to declare array of pointers.

When you need the more than one pointers to the same struct you do this

struct node * left;
 strcut node * right;

so why can't you do this

struct node *child[2];

Similarly struct node *p[26] is also possible but everything depends on your requirement and implementation.

One requirement , As I think think of d-ary tree (where each node has d nodes) And you want to directly nevigate to it's children from parent node.

so struct node *child[d] is legal (where d is #defined )