2 dimension Array , saving data from SD card

Hi,

I am trying to save data in 2 dimension array by using this commands:

     char IRcode2[i][j];
     IRcode2[1][3] = '1';
     IRcode2[0][3] = '2';
     IRcode2[2][3] = '4';
     for (int i= 3 ; i <= 3; i++ ) {
       for (int j= 0 ; j < 3; j++ ) {
            Serial.print("j =  ");
              Serial.print(j);
                Serial.print("  , i = ");
                      Serial.println(i);
                Serial.println(IRcode2[j][i]);};

but in serial print I got these:

j =  0  , i = 3
4
j =  1  , i = 3
4
j =  2  , i = 3
4

why??

I have no idea... I need your help

Thanks

What were i and j at the first line of your snippet when this line was run:

     char IRcode2[i][j];

try:

     char IRcode2[3][4];

Thank you , I changed it and it works!

So I have to declare the size of array at first!!!!!

parmares:
Thank you , I changed it and it works!

So I have to declare the size of array at first!!!!!

You must always create the array before you use it. Your i and j were set in the piece of code you didn't include, so I have no idea how big your array actually was. Basically, you were writing to random memory, which causes all sorts of problems.

you right!
I didn't mention it. I just declared i and j like this:
int i, j;

thank you again, now it works well

remove those declarations of i and j, since they are only used in your for loops, where you also declare them. This is a different i and j and would cause confusion. It will stop these sort of problems occurring, as the compiler will warn you.