Go Down

Topic: 2-dimensional arrays? (Read 1 time) previous topic - next topic

jw

Jan 05, 2007, 07:58 pm Last Edit: Jan 05, 2007, 07:58 pm by jw Reason: 1
is there any possibility to create a 2-dimensional array? like int foobar[8][8] = ...?

if yes, how would the syntax look like?

thanks in advance!
jens

CosineKitty

#1
Jan 05, 2007, 08:57 pm Last Edit: Jan 05, 2007, 08:59 pm by CosineKitty Reason: 1
try this...
Code: [Select]

int foobar[8][8] = {
   {5, 7, 2, 3, 5, -4, 3, 8},      // this is foobar[0][...]
   {12, 8, 6, 2, -9, 5, 4, 3},    // this is foobar[1][...]
   //... etc ...
};


Then foobar[0][1] == 7, and foobar[1][0] == 12, just to give you an idea of the order of the dimensions.

jw

aaah very good. i tought it would work like this but tried to separate the second-level arrays by ; instead of ,
stupid me.

thanks, cosine kitty!

Go Up