digitalmars.D - So many years I was following D...
- Iamgottingcrazy <shouldIlearnthis digitalmars.com> Oct 14 2009
- bearophile <bearophileHUGS lycos.com> Oct 14 2009
- Fawzi Mohamed <fmohamed mac.com> Oct 14 2009
- "AJ" <aj nospam.net> Oct 16 2009
- Gide Nwawudu <gide btinternet.com> Oct 14 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.
Oct 14 2009
Iamgottingcrazy:Should I bear this??
With D1 it seems to work: http://codepad.org/hpslrHHs Bye, bearophile
Oct 14 2009
On 2009-10-14 10:48:10 +0200, bearophile <bearophileHUGS lycos.com> said:Iamgottingcrazy:Should I bear this??
With D1 it seems to work: http://codepad.org/hpslrHHs Bye, bearophile
maybe because you actually used the correct sequence of dimensions... int[2][3] x; x.length is 3, this is a 3 dimensional array of 2 dimensional arrays... Fawzi
Oct 14 2009
bearophile wrote:Iamgottingcrazy:Should I bear this??
With D1 it seems to work: http://codepad.org/hpslrHHs Bye, bearophile
He had a technical problem and worded his subject line that way?
Oct 16 2009
On Wed, 14 Oct 2009 04:26:38 -0400, Iamgottingcrazy <shouldIlearnthis digitalmars.com> wrote: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.
Looks like a version of the following bug. http://d.puremagic.com/issues/show_bug.cgi?id=2477 Gide
Oct 14 2009









Fawzi Mohamed <fmohamed mac.com> 