I just build my fist LED cube and want to expand the test code a bit. To address each LED of my 3x3x3 cube I want to use a corresponding three-dimensional array, but I got errors on its initialization.
Here’s what I did:
int cube_matrix[3][3][3] =
{
{ {0}, {0}, {0} },
{ {0}, {0}, {0} },
{ {0}, {0}, {0} }
},
{
{ {0}, {0}, {0} },
{ {0}, {0}, {0} },
{ {0}, {0}, {0} }
},
{
{ {0}, {0}, {0} },
{ {0}, {0}, {0} },
{ {0}, {0}, {0} }
};
Here’s the error I get:
error: expected unqualified-id before ‘{‘ token
I could use a for loop to initialize my array and get things done but my initialization seems correct to me, and I want to know what I did wrong.
If you’re really aiming for allocating the whole thing with zeros, you could use a simplified initializer:
If you’d like more than zeros in there, you can do that too:
With output that looks like this: