I have a struct for a tile (all properties are previously-defined enums)
typedef struct {
ShapeType shape;
ColorType color;
PatternType pattern;
IconType icon;
} TileDefinition;
And I want to create another struct that holds 16 tiles, for a "board". Something like this:
typedef struct {
TileDefinition[16]
} BoardDefinition;
And then I want to be able to loop through that, like so:
for(int i=0;i<16;i++) {
TileDefinition tileDef = boardDef[i];
// Do something with tileDef
}
But obviously the setup for the BoardDefinition struct isn't working. How can I set that up? Where should I and shouldn't I use pointers?
Thanks
struct { TileDefinition[16] }looks really odd to me. What's wrong withstruct { TileDefinition tiles[16]; }and then usingboardDef.tiles[i]?