#### Archived

This topic is now archived and is closed to further replies.

# Need some help with structs

This topic is 6920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! It''s been a while I dont post/read here... was somewhat away from programming, but now I hope to be back for some time at least. Nice to see ya''ll again =]. I need to make a struct that has other structs inside it. Im not sure how to explain (but Im pretty sure it exists and is widely used), so Ill give an example. It would be accessed like this : object[10].property[3].active = 1; player[2].status.hp.poisoned = 0; Can someone clear this up to me? Thanks a lot Oh, and please dont say "Use classes! Structs suck!" cause Im not really willing to stop and learn it and then apply. I want to do it now, and Im somewhat used to structs, so Ill stick with it for now. Thanks a lot, -RoTTer

##### Share on other sites
Here''s how you can do something similar to your first example:
struct prop{   int active;};struct obj{   struct prop property[5];};struct obj object[20];int main(void){   object[10].property[3].active = 1;}

I hope that helps!

##### Share on other sites
Woa, thanks a lot!
It worked perfectly! Just as I wanted it to be :>

Thanks again, and sorry for the delay answering =]

Cya,-
RoTTer

• 15
• 13
• 35
• 39