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?
This is a discussion on Storing an array of structures? within the C Programming forums, part of the General Programming Boards category; What's the proper specification for an array of structures? Also how can I call a structure from an array once ...
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?
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..
So would it be like this?: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};
etc... ?Code:double main (void) { Operator op[12]={mult, add, neg}; }
that's exactly it and here's a good writeup on array of structures
http://faq.cprogramming.com/cgi-bin/...&id=1073086407
Last edited by itCbitC; 12-14-2008 at 10:20 PM.
main returns int, always. Not double, not void, not something else.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^