how to initialize an array of struct

westcity westcity1973 at hotmail.com
Thu Feb 12 01:20:07 PST 2009


My code is as following:

struct Point {
        float x, y, z ;
};

int main ()
{
        Point[3] pts = [
                {1.0, 0.0, 0.0} ,
                {0.0, 1.0, 0.0} ,
                {0.0, 0.0, 1.0}
        ];

        return 0 ;
}

But, the compiler report "Error: array initializers as expressions are not allowed".

Then, how do I initialize an array of struct ? 



More information about the Digitalmars-d-learn mailing list