I have a struct TREE
defined this way:
typedef struct TREE {
NODE *head;
} TREE;
and a struct NODE
defined as:
typedef struct NODE {
char boss[30];
char name[30];
struct NODE *firstChild;
struct NODE *secondChild;
struct NODE *thirdChild;
struct NODE *fourthChild;
} NODE;
In my main, I have:
TREE companyStructure;
TREE *treeptr;
treeptr = &companyStructure;
strcpy(treeptr->head->name, "Ben");
But this gives me a segmentation fault. Can someone help me explain why this is the case? Is there some memory management that I'm not doing that I need to be doing?