Pages: [1]   Go Down
Author Topic: 2-dimensional arrays?  (Read 1299 times)
0 Members and 1 Guest are viewing this topic.
Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 11
I Love YaBB 2!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 05, 2007, 01:58:47 pm by jw » Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

try this...
Code:
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.
« Last Edit: January 05, 2007, 02:59:36 pm by CosineKitty » Logged

Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 11
I Love YaBB 2!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: [1]   Go Up
Jump to: