Multiple Dynamic Array

Bill Baxter dnewsgroup at billbaxter.com
Mon Dec 25 17:52:05 PST 2006


efgee wrote:
> Hi,
> as a newbie I have some difficulties with creating and working with multiple
> dynamic arrays.

Dynamic doesn't mean that the memory is automatically allocated for you.
int[][][] A just basically sets up a base pointer. To actually give it 
some memory you have to either use new or set the .length property of 
every dimension.  So you'll need a nested loop like:

    A.length = 64;
    for(i = 0; i <= 63; i ++)
    {
       A[i].length = 64;
       for(j = 0; j <= 63; j ++)
       {
	  A[i][j].length = 64;
        }
      }
    }

Warning -- above code not tested.

--bb


More information about the Digitalmars-d-learn mailing list