Subj : Re: How to deal with Tree with several branchs? To : comp.programming From : Krzysztof Olczyk Date : Sun Jul 24 2005 12:16 am Uzytkownik "Davy" napisal w wiadomosci news:1122113553.398175.35300@z14g2000cwz.googlegroups.com... > Now I use the structure: > typedef struct gnodes > { > int level; //tree level > struct gnodes* pfather; > struct gnodes* pbrother; > struct gnodes* pchild; > struct gnodes* puncle; > } gnode; what about the following?: typedef struct gnode { int level; int somedata; int child_count; struct gnode *children[]; } gNode; and then it would be allocated like: gNode* CreateNode(int childcount) { gNode *node; node = malloc(sizeof(gNode) + childcount * sizeof(gNode*)); node->child_count = childcount; } Note: This solution is only C99-compliant. -- Regards, Krzysiek .