So many years I was following D...
Iamgottingcrazy
shouldIlearnthis at digitalmars.com
Wed Oct 14 01:26:38 PDT 2009
Should I bear this??
module teststructarray;
import std.stdio;
import core.stdc.stdlib:system;
struct Point
{
int x;
int y;
}
static Point[2] pArray1=
[
{0,0},{0,1},//watch here!
];
static Point pArray2[2][3]=
[
[{0,0},{0,1},{0,2}],
[{1,0},{1,1},{1,2}],//watch here,without the last comma,the prog can't get compiled!!
];
void main()
{
foreach(int i,point;pArray1)
writefln("Point(%d)={%d,%d}",i,pArray1[i].x,pArray1[i].y);
foreach(points;pArray2)
{
foreach(point;points)
{
writef("Point(%d,%d)\t",point.x,point.y);
}
write("\n");
}
system("pause");//watch when this line gets executed
}
Try compile and run.
More information about the Digitalmars-d
mailing list