简体   繁体   中英

Accessing a Character Pointer in a Structure Array

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?

If, as you commented, mytable is an array of pointers to structures, then instead of:

mytable[i].word

You should have:

mytable[i]->word

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM