Need some help with structs
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
Here''s how you can do something similar to your first example:
I hope that helps!
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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement