-
creating structures help
hello,
I have read the tutorial on strutures and I have a simple question.
I would try it out myself but don't have a compiler on hand.
Say I've defined a struture
Code:
struct example
{
int x;
};
example an_example; //Treating it like a normal variable type
an_example.x=33; //How to access it
Now the above has "created" a variable called an_example to access this particular structure.
As my program runs it will need to access different instances of the structure so how to I get it to "create/access an instance of structure?
In in the above code, rather than "an_example" can I actually have an array or something? that way I can access different elements in that array hence different instances of the structure?
-
Code:
example an_example[3];
an_example[0].x = 8; //1st variable
an_example[1].x = 32; //2nd variable
an_example[2].x = 5; //3rd variable
-
-
>>what do you mean it does not work?
That's just his signature. Ignore it.
-
lol, I feel so n00bi, I realized it and changed the post but you beet me to it!
Thanks again to funkydude9