I currently have this code:
struct LAYOUT {
WORD a [8] = {::Rook, ::Knight, ::Bishop, ::Queen, ::King, ::Bishop, ::Knight, ::Rook};
WORD b [8] = {::Pawn};
WORD empty [32] = {::None};
WORD c [8] = {::Pawn+0x6};
WORD d [8] = {::Rook+0x6, ::Knight+0x6, ::Bishop+0x6, ::Queen+0x6, ::King+0x6, ::Bishop+0x6, ::Knight+0x6, ::Rook+0x6};
}chessLayout;
LAYOUT* chessboard = &chessLayout;
The global enum
fields such as ::Rook
represent a word, ex: 0x2656
.
My objective here is to enumerate all the elements in this structure, so I wrote this piece of code:
for(int i = 0; sizeof(LAYOUT) / 2;i++){
printf("%x", *(reinterpret_cast<WORD*>(chessboard+i)));
}
However this returns me the first value right but then returns unrelated junk values and not the elements in the struct.
Any ideas?
Thanks in advance