how to initialize an array of struct
westcity
westcity1973 at hotmail.com
Fri Feb 13 01:41:51 PST 2009
bearophile дµ½:
> westcity Wrote:
> > But, the compiler report "Error: array initializers as expressions are not allowed".
> > Then, how do I initialize an array of struct ?
>
> Move the definition out of main (note that ; after the struct isn't required):
>
> struct Point {
> float x, y, z;
> }
>
> Point[3] pts = [{1.0, 0.0, 0.0},
> {0.0, 1.0, 0.0},
> {0.0, 0.0, 1.0}];
>
> void main () {}
>
> Bye,
> bearophile
It is perfect, thanks.
More information about the Digitalmars-d-learn
mailing list