user11827: 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<image_height; i++) {
    for (int j=0; j<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?

user7282: You are trying to use more memory than you have available: 96 * 56 * 2 = 10.752KBytes. Not much that the MCU can do when this happens. 
If you look into the datasheet, you'll see that your microcontroller (ATmega328p) only has 2KBytes of RAM. 
I guess the question then, is to ask yourself if you really need that large an array. You may consider getting an external flash chip or an SDcard shield. If you only need it for read-only purposes (such as a lookup table), you can use some of your flash program memory (you have 32KBytes).

user1585: 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.

11827: 

<p>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.</p>

<p>Code:</p>

<pre class="lang-C++ prettyprint-override"><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");
}
</code></pre>

<p>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?</p>

<p>Do 2 dimensional arrays work differently in Arduino or is it a space issue?</p>
 7282: <p>You are trying to use more memory than you have available: 96 * 56 * 2 = 10.752KBytes. Not much that the MCU can do when this happens. </p>

<p>If you look into the <a href="http://www.atmel.com/Images/doc8161.pdf" rel="nofollow">datasheet</a>, you'll see that your microcontroller (ATmega328p) only has 2KBytes of RAM. </p>

<p>I guess the question then, is to ask yourself if you really need that large an array. You may consider getting an external flash chip or an SDcard shield. If you only need it for read-only purposes (such as a lookup table), you can use some of your <a href="https://www.arduino.cc/en/Reference/PROGMEM" rel="nofollow">flash program memory</a> (you have 32KBytes).</p>
 1585: <p>2D arrays work fine on arduino, but you run out of space very quickly.</p>

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

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