I have 2 structs in my program.
linked list of id's, and a WORD
typedef struct related
{
int id;
struct related* next;
} RELATED;
typedef struct word
{
int id;
char name[NAME_LEN];
RELATED *related;
} WORD;
i want to hold an array of WORD's and i want it to be dynamic.
I have 2 pointers to words:
WORD* word1;
WORD* word2;
with values.
when i am tryin to dynamically allocate it in this way:
WORD** arr = (WORD**)malloc(sizeof(WORD*)*10) // to hold 10 words
and trying to add a word to an array, the first one is added properly, but the second one run over the first one:
arr[0] = word1;
arr[1] = word2;
when i am defining the array this way:
WORD* arr[40];
the same add of words works just fine
arr[0] = word1;
arr[1] = word2;
can't quite find the right way of this dynamic allocation.. thnx for help!