# Storing an array of structures?

• 12-14-2008
Sparrowhawk
Storing an array of structures?
What's the proper specification for an array of structures?

Also how can I call a structure from an array once I have them in there?
• 12-14-2008
itCbitC
Just like you would declare an array of ints for ex. except that each element is of the type struct instead of an int.
• 12-14-2008
Sparrowhawk
Quote:

Originally Posted by itCbitC
Just like you would declare an array of ints for ex. except that each element is of the type struct instead of an int.

Ok say I have this struct..
Code:

```typedef struct Operator {         char symbol;         int operands;         union         {                 void *f;                 double (*f0)(void);                 double (*f1) (double x);                 double (*f2) (double x, double y);         } }Operator; Operator mult={'*',2,multiply1}; Operator add={'+',2,add1}; Operator neg={'-',1,neg1}; Operator divide={'/',2,divide1}; Operator square={'sq',1,square1}; Operator sqrt={'sqrt',1,squareRoot1}; Operator min={'m',2,min1}; Operator max={'M',2,max1}; Operator expo={'^',2,expo1}; Operator pi={'pi',0,pi}; Operator loga={'log',1,L}; Operator expon={'e^',1,E};```
So would it be like this?:

Code:

```double main (void) {         Operator op[12]={mult, add, neg}; }```
etc... ?
• 12-14-2008
itCbitC
that's exactly it and here's a good writeup on array of structures
http://faq.cprogramming.com/cgi-bin/...&id=1073086407
• 12-15-2008
Elysia
main returns int, always. Not double, not void, not something else.