Is it possible to use an array initializer as an array (sort of like a string literal?)
#define TETRAMINO_I {{1,1,1,1},{0,0,0,0}}
printf("%c",(TETRAMINO_I[0][0]) ? "#" : ' ');
(This code obviously doesn't work.
I have come up with the following solution (bypassing this requirement)
#define TETRAMINO_I {{1,1,1,1},{0,0,0,0}}
#define TETRAMINO_J {{1,1,1,0},{0,0,1,0}}
#define TETRAMINO_L {{1,1,1,0},{1,0,0,0}}
#define TETRAMINO_O {{1,1,0,0},{1,1,0,0}}
#define TETRAMINO_S {{0,1,1,0},{1,1,0,0}}
#define TETRAMINO_T {{1,1,1,0},{0,1,0,0}}
#define TETRAMINO_Z {{1,1,0,0},{0,1,1,0}}
typedef unsigned char byte;
typedef struct tetraminos{
char I[2][4];
char J[2][4];
char L[2][4];
char O[2][4];
char S[2][4];
char T[2][4];
char Z[2][4];
}tet_minos_t;
tet_minos_t tet_mino_blocks{ TETRAMINO_I,TETRAMINO_J,TETRAMINO_L,TETRAMINO_O,TETRAMINO_S,TETRAMINO_T,TETRAMINO_Z};
Using a global instance of a struct. However, when trying to use:
newMino->blocks = (char**)tet_mino_blocks.I;
printf("%c",(newMino->blocks[0][0]) ? "#" : ' ');
I am unable to print (get segmentation fault)