我有强制.hpp包含这些东西:
enum class TileType : uint16_t
{
EMPTY = 0,
BLOCK = 1,
OBSTACLE = 2,
EVIL_DUDE = 3,
EVIL_SHOOT = 4,
MY_SHOOT = 5,
POWERUP = 6,
OTHER = 7
};
和
struct GetMap
{
CommandType type;
uint16_t width;
uint16_t height;
TileType tile[0];
} __attribute__((packed));
我的问题是,在创建变量之后:
GetMap *map = new GetMap[(10 * 10) * sizeof(TileType)];
并用以下值填充:
map->tile[(y * 10) + x] = TileType::BLOCK;
如何在终端上打印整个 GetMap 的 tile 值?我曾经想过使用演员阵容,但我遇到了一些问题。