Bidimensional dynamic array problem
orgoton
orgoton at mindless.com
Tue Mar 6 07:25:32 PST 2007
I have this
struct Vertex{
(...)
float z;
}
then:
Vertex vData[][];
Somewhere later:
vData.length=sizeX;
foreach(Vertex strip[]; vData[]) strip.length=sizeY;
Here the array is initialized. So far, I think I haven't done anything illegal. (SizeX and SizeY are runtime values, ushort vars). So first I say how many strips I want, and next, I put in how many elements that strip will have.
ulong m;
foreach (Vertex[] strip; vData)
{
foreach (Vertex vertex; strip)
{
file.read(vertex.height);
m++;
}
}
Here I read the values from a file. First, I select a strip, and then go through all the elements of that array and read their values. "m" is a counter to see how many elements where read.
The thing is, m=0 at the end of the loop. What did I do wrong?
More information about the Digitalmars-d-learn
mailing list