title: Problems populating a multi-dimensional array of structs in C++ with an initialisation list
body: <p>I'm creating a text adventure with room names, descriptions and spaces for hints and items.</p>
  <p>This is part of the solution so far, a simple struct with four string entries. A requirement is to keep the rooms initialisation data readable and editable as the 4x4 array works as a grid for my game world.</p>
  <pre><code>using namespace std;
  #include &lt;string&gt;
  struct Room
  {
      string name;
      string description;
      string itemHint;
      string item;
  };
  Room rooms[4][4]= {
  {{&quot;...&quot;, &quot;...&quot;, &quot;...&quot;, &quot;...&quot;},
  {&quot;...&quot;, &quot;...&quot;, &quot;...&quot;, &quot;...&quot;},
  {&quot;...&quot;, &quot;...&quot;, &quot;...&quot;, &quot;...&quot;},
  {&quot;...&quot;, &quot;...&quot;, &quot;...&quot;, &quot;...&quot;}}, // rooms[0..3][0] data
  
  {{&quot;...&quot;, &quot;...&quot;, &quot;...&quot;, &quot;...&quot;}, // and so on
  </code></pre>
  <p>Now this works to some extent. But, when printing the rooms map of the game world I'm getting duplicate entries. The code is duplicating the room data four times per row [0..0][0..3].</p>
  <pre><code>void PrintMap()
  {
      cout &lt;&lt; endl;
      for (int v = 0; v &lt; 4; v += 1)
      {
          for (int h = 0; h &lt; 4; h += 1)
          {
              if (currentRoom.h == h &amp;&amp; currentRoom.v == v)
                  cout &lt;&lt; &quot;@&quot;;
              else
                  cout &lt;&lt; &quot; &quot;;
              cout &lt;&lt; rooms[h, v]-&gt;name;
              string charstring = rooms[h, v]-&gt;name;
              int chars = charstring.length();
              int endSpaces = 24 - 1 - chars;
              for (int charSpaces = 1; charSpaces &lt; endSpaces + 1; charSpaces += 1)
                  cout &lt;&lt; &quot; &quot;;
          }
          cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl;
      }
  }
  </code></pre>
  <p>Here is a screenshot of the console application printed room map to help better explain this:</p>
  <p><a href="https://i.stack.imgur.com/2l9XR.jpg" rel="nofollow noreferrer">room map</a></p>
  <p>I'm almost understanding why this occurs, but perhaps someone could explain it and has a valid solution. Of course as I've said I'd like to keep the code format for the rooms data readable, I gladly accept any code design additions.</p>