The objective is to build a "infinite" tree using dynamic arrays.
items[3]
- MENUITEM
- items[2]
- MENUITEM
-items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[2]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
I define the structure:
typedef struct MENUITEM {
char id, count;
char *description;
};
And I can allocated items dynamically with:
char count;
MENUITEM items[], *items_ptr;
count++;
realloc( items_ptr, count * sizeof(struct MENUITEM) );
The problem is that inside the structure I cannot assign again the structure itself like:
typedef struct MENUITEM {
char id, count;
char *description;
MENUITEM items[], *items_ptr;
};
The compiler outputs: error: field ‘items’ has incomplete type; what am I doing wrong here ? Thanks for any help provided.