You have to free each piece of allocated memory: i. e. the word
fields in all of the struct, then the arrayOfWords
array itself too:
for (int i = 0; i < NUM_WORDS; /* whatever it is */ i++) {
free(arrayOfWords[i].word);
}
free(arrayOfWords);
Some good advice: don't realloc()
in each and every step - it's tedious. Use an exponentially growing storage (double the space when it's exceeded).