Problem with 2 and 3 dimensional array

I wrote a game in processing and then decided to edit it and load it to arduino mega. However, i have problems with arrays. I know Processing uses java and Arduino uses c++. My code:

byte Blocks[][][] = 
{
  {
   {
     1,1
   },
   {
    1,1 
   }
  },
  {
    {
      0,0,2
    },
    {
     2,2,2 
    }
  },
  {
    {
     3,3,3 
    },
    {
     0,0,3 
    }
  },
  {
    {
     4,4,0 
    },
    {
     0,4,4 
    }
  },
  {
    {
     0,5,5 
    },
    {
     5,5,0 
    }
  },
  {
   {
    0,6 
   },
   {
    6,6 
   },
   {
    0,6 
   }
  },
  {
    {
     7,7,7,7 
    }
  }
};

and also when i reassign an array

//CurrentBlock is byte[][]
CurrentBlock = Blocks[0];

What should i do to solve this problem?

However, i have problems with arrays.

Only you know what the problems are.

What should i do to solve this problem?

What problem?

Firstly, you forgot to state the actual problem.

Secondly, C and C++ do not have [][][] arrays. You need to explicitly specify the sizes. When declaring an array with an initializer you can omit the size in the first pair of [], but not in the rest of them.

And you cannot declare a "jagged" multidimensional array in C or C++: multidimensional arrays are always rectangular.

Thirdly, naked arrays in C and C++ are not copyable. You cannot assign one array to another. If you want to copy an array, use memcpy or something similar.

MrDeniz:

//CurrentBlock is byte[][]

CurrentBlock = Blocks[0];




What should i do to solve this problem?

I see no problem. CurrentBlock is a 2D array pointer and it points to the first (zeroth) 2D array in the big 3D array.

Changing the data values pointed to will change the original data as there is no "copy" of the data.

MorganS:
I see no problem. CurrentBlock is a 2D array pointer and it points to the first (zeroth) 2D array in the big 3D array.

While the OP’s description of what CurrentBlock is is syntactically incorrect, it is definetely not a pointer. It is intended to be a 2D array.

The OP wants to copy a 2D subarray of 3D array Blocks to CurrentBlock. This is possible (once the declarations are corrected), but not by plain assignment.