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
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...
int array[5][2] =
{
{1,1,1,1,1},
{1,1,1,1,1}
};
ok thanks.
what about for 3D arrays?
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.
Sure you can. You can initialize any number of dimension of arrays that you can stand to do. (IE: whatever doens't make you go insane while you're typing it all out.Quote:
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:
Now you know why I kept it short (ie: 2x2x2).Code:int array[2][2][2] =
{
{
{1,2},
{3,4},
},
{
{5,6},
{7,8},
},
};
Quzah.
i should be able to work that :) thanks a lot.