在结构数组中打印值,C ++

时间:2017-04-05 11:54:04

标签: c++

我有强制.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 值?我曾经想过使用演员阵容,但我遇到了一些问题。

0 个答案:

没有答案