How do u go about initialising 2D and 3D arrays and giving them all values? They are integer values, btw.

i know " int array[] = { 1 }; " is for 1D arrays of integers, but i cant work out particularly how 3D arrays would be set...

Printable View

- 08-01-2002fryInitialising 2D and 3D arrays
How do u go about initialising 2D and 3D arrays and giving them all values? They are integer values, btw.

i know " int array[] = { 1 }; " is for 1D arrays of integers, but i cant work out particularly how 3D arrays would be set... - 08-01-2002frenchfry164
int array[5][2] =

{

{1,1,1,1,1},

{1,1,1,1,1}

}; - 08-01-2002fry
ok thanks.

what about for 3D arrays? - 08-01-2002frenchfry164
I don't think there is a way to initialize a 3D array with starting numbers. I think you have to do them value by value.

- 08-01-2002quzahQuote:

*Originally posted by frenchfry164*

**I don't think there is a way to initialize a 3D array with starting numbers. I think you have to do them value by value.**

Here ya go:

Code:`int array[2][2][2] =`

{

{

{1,2},

{3,4},

},

{

{5,6},

{7,8},

},

};

Quzah. - 08-01-2002fry
i should be able to work that :) thanks a lot.