Arduino Uno not able to handle 2-dimensional array Now the code I'm writing in Arduino (Using Arduino) uses multiple 2-dimensional arrays. Now when I print some thing using the Serial Monitor it prints it correctly but when I declare and initialize the 2-dimentional array it won't print it.

Code:

void setup()
{
  Serial.begin(9600);
  int image_width = 56;
  int image_height = 96;


  int image_result[image_width][image_height];
  for (int i=0; i&lt;image_height; i++) {
    for (int j=0; j&lt;image_width; j++) {
      image_result[j][i] = 5;
    }
  }

  Serial.print("code works");
}


Now in this case "code works" does not print but when I remove the array declaration and initialization code works is printed. What is the problem?

Do 2 dimensional arrays work differently in Arduino or is it a space issue?
2D arrays work fine on arduino, but you run out of space very quickly.

An uno has 2 kilobytes of ram; your array has 56*96 = 5376 2-byte elements.

I would guess that you are writing over some critical memory value with a 5 at some point causing the program to fail.