Hello Gentlemen, Ladies,<br><br>Not sure if you can help me ?<br>I am trying to reference items in a structure within a structure. And also allocating memory with "malloc".<br><br>Please see I have created a Structure (word_entry) , and then created another Structure (Node) which contains previous structure.<br><br>The reason I have done this is because I will be reading string of characters of various lengths and allocating memory dynamically to each String depending on length.<br>Rather than just make every word sit in a fixed length array even when one word may be only 2 chars in length.<br>-------------------------------------------------------- <br>struct word_Entry {<br> char *word /* String Word entry */<br>};<br><br>struct Node {<br> struct Node *leftPtr;<br> struct word_Entry *entry;<br> struct Node *rightPtr;<br>};<br><br>typedef struct Node TREENODE;<br>typedef TREENODE *TREENODEPTR;<br><br>void insertNode (TREENODEPTR *treePtr, char *dictentry)<br>--------------------------------------------------------<br>Question (1)<br>============<br>How do I allocate memory to each structure dynamically<br>based on "String" length. (in function "insertNode"
<br><br>void insertNode (TREENODEPTR *treePtr, char *dictentry)<br>{<br>...<br>...<br><br>*treePtr = (TREENODEPTR)malloc(sizeof((char)* strlen ??????;<br><br>...<br>...<br>}<br><br>-------------------------------------------------------<br>Question(2)<br>==========<br>How do I copy a "String" into the Structure<br>strcpy( (*treePtr).??????? , dictentry );<br>