Array size

Hey, I have three dimensional array. I need to find the amount of rows in it (example below). How can I do it?

Example array, trying to find value x.

int array[X][2][3] = {
{{1, 2, 3}, {2, 2, 2}},
{{2, 3, 2}, {3, 5, 2}}, 

...    (n lines)

{{1, 1, 1}, {3, 2, 2}}
};

I cannot change the structure of the array as it is blueprint for controlling RGB LEDs row by row.

I can't see x in the code that you posted. Perhaps if you had used code tags when you posted it ....

sizeof (array) / 12

Though that's assuming 16 bit ints.

Gollex:
Hey, I have three dimensional array. I need to find the amount of rows in it (example below). How can I do it?

Example array, trying to find value x.

int array[X][2][3] = {

{{1, 2, 3}, {2, 2, 2}},
{{2, 3, 2}, {3, 5, 2}},

...    (n lines)

{{1, 1, 1}, {3, 2, 2}}
};




I cannot change the structure of the array as it is blueprint for controlling RGB LEDs row by row.

The size of your three dimensional array can be determined this way:

int array[][2][3] = {
  {{1, 2, 3}, {2, 2, 2}},
  {{2, 3, 2}, {3, 5, 2}},
  {{2, 3, 2}, {3, 5, 2}},
  {{1, 1, 1}, {3, 2, 2}}
};

void setup()
{
  Serial.begin(9600);
  Serial.println(sizeof(array)/sizeof(array[0]));
  Serial.println(sizeof(array)/sizeof(array[0][0]));
  Serial.println(sizeof(array)/sizeof(array[0][0][0]));
}

void loop() 
{
}

Wouldn't that be:

void setup()
{
  Serial.begin(9600);
  Serial.println(sizeof array         / sizeof array[0]);
  Serial.println(sizeof array[0]     / sizeof array[0][0]);
  Serial.println(sizeof array[0][0] / sizeof array[0][0][0]);
}

johnwasser:
Wouldn't that be:

void setup()

{
  Serial.begin(9600);
  Serial.println(sizeof array        / sizeof array[0]);
  Serial.println(sizeof array[0]    / sizeof array[0][0]);
  Serial.println(sizeof array[0][0] / sizeof array[0][0][0]);
}

Ha! I guess it just depends on what you were getting the sizeof()!

The answer to OP's question are in both our responses...