Reputation: 9
I have an array of pointers to structs that each have a char pointer that is pointing to a string. I want to compare this word to another word.
I compile my code but get this error:request for member word in something not a structure or union. on this line:
strcmp(mytable[i].word, word) == 0)
What am I doing wrong?
Upvotes: 0
Views: 142
Reputation: 137382
If, as you commented, mytable is an array of pointers to structures, then instead of:
mytable[i].word
You should have:
mytable[i]->word
Upvotes: 1