the title pretty much says it all i have a struct with an array of struct as one of its member and I can't figure out how to access
struct Member{
short x;
...
};
struct List{
struct Member members[MAX_MEMBER];
...
};
short function(const struct List*n){
if((n->members[i])->x ...)
...
}
I tried somethin like that but it doesn't work. Thanks for your answer
n->members
is an array of struct Member
, not an array of pointers. Hence n->members[i]
is a struct Member
, not a struct Member *
. You should therefore access its members using .
and not ->
. Try:
if (n->members[i].x ...)
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.