title: Storing numbers manually into int ** makes some numbers random | c++
body: <p>I'm trying to fill an array of int array to create a tilemap for a videogame. However I've used switch case and I tried to fill the map when initializing it but some of the number are random for an unknown reason.</p>
  <p>Here's the code:</p>
  <pre><code>int **Process::get_story_map(int lvl)
  {
      int **map = new int *[10];
      switch (lvl)
      {
          case (0): {
              int line01[10] = {5, 0, 1, 1, 2, 2, 1, 1, 0, 5};
              int line02[10] = {0, 0, 1, 1, 2, 2, 1, 1, 0, 0};
              int line03[10] = {1, 1, 1, 1, 2, 2, 1, 1, 1, 1};
              int line04[10] = {1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
              int line05[10] = {2, 2, 1, 0, 0, 0, 0, 1, 2, 2};
              int line06[10] = {2, 2, 1, 0, 0, 0, 0, 1, 2, 2};
              int line07[10] = {1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
              int line08[10] = {1, 1, 1, 1, 2, 2, 1, 1, 1, 1};
              int line09[10] = {0, 0, 1, 1, 2, 2, 1, 1, 0, 0};
              int line10[10] = {5, 0, 1, 1, 2, 2, 1, 1, 0, 5};
              map[0] = line01;
              map[1] = line02;
              map[2] = line03;
              map[3] = line04;
              map[4] = line05;
              map[5] = line06;
              map[6] = line07;
              map[7] = line08;
              map[8] = line09;
              map[9] = line10;
          }
          case (1): {
              int line01[10] = {5, 0, 1, 1, 1, 1, 1, 1, 0, 5};
              int line02[10] = {0, 0, 1, 1, 2, 2, 1, 1, 0, 0};
              int line03[10] = {1, 1, 1, 1, 2, 2, 1, 1, 1, 1};
              int line04[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
              int line05[10] = {2, 2, 2, 1, 2, 2, 1, 2, 2, 2};
              int line06[10] = {2, 2, 2, 1, 2, 2, 1, 2, 2, 2};
              int line07[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
              int line08[10] = {1, 1, 1, 1, 2, 2, 1, 1, 1, 1};
              int line09[10] = {0, 0, 1, 1, 2, 2, 1, 1, 0, 0};
              int line10[10] = {5, 0, 1, 1, 2, 2, 1, 1, 0, 5};
              map[0] = line01;
              map[1] = line02;
              map[2] = line03;
              map[3] = line04;
              map[4] = line05;
              map[5] = line06;
              map[6] = line07;
              map[7] = line08;
              map[8] = line09;
              map[9] = line10;
              break;
          }
          default:
              return (NULL);
      }
      for (int i = 0; i &lt; 10; i++) {
          for (int j = 0; j &lt; 10; j++) {
              std::cout &lt;&lt; map[i][j] &lt;&lt; &quot; &quot;;
          std::cout &lt;&lt; std::endl;
      }
      std::cout &lt;&lt; &quot;--------------------------------&quot; &lt;&lt; std::endl;
      return (map);
  }
  </code></pre>
  <p>Here's where I call it</p>
  <pre><code>int main(void)
  {
      // Initialization
      //--------------------------------------------------------------------------------------
      Process *process = new Process();
      // int **map = process-&gt;generate_arcade_map();
      int **map = new int *[10];
      map = process-&gt;get_story_map(1);
      for (int i = 0; i &lt; 10; i++) {
          for (int j = 0; j &lt; 10; j++) {
              std::cout &lt;&lt; map[i][j] &lt;&lt; &quot; &quot;;
          }
          std::cout &lt;&lt; std::endl;
      }
  }
  </code></pre>
  <p>And here's the output:</p>
  <pre><code>5 0 1 1 1 1 1 1 0 5 
  0 0 1 1 2 2 1 1 0 0 
  1 1 1 1 2 2 1 1 1 1 
  1 1 1 1 1 1 1 1 1 1 
  2 2 2 1 2 2 1 2 2 2 
  2 2 2 1 2 2 1 2 2 2 
  1 1 1 1 1 1 1 1 1 1 
  1 1 1 1 2 2 1 1 1 1 
  0 0 1 1 2 2 1 1 0 0 
  5 0 1 1 2 2 1 1 0 5 
  --------------------------------
  5 0 1 1 1 1 1 1 0 5 
  0 0 1 1 2 2 -2070125006 32711 0 0 
  1 1 -2068490400 32711 5 0 1 0 1 0 
  -2068507136 32711 -2070171513 32711 1 1 0 0 -116061664 32766 
  -2066141792 32711 32711 0 0 0 -2068490400 32711 1 0 
  1 0 -1835315192 22061 -2068507136 32711 -2070171513 32711 53 0 
  3432 22061 -1835306944 22061 1 0 0 0 -116061680 32766 
  -1835322135 22061 0 0 -1835306944 22061 -1835306936 22061 -116061695 32766 
  -1835306944 32711 -125382144 99592016 1 2 0 0 -1835315192 22061 
  -116061152 22061 0 0 -2062934976 32711 -2067049860 32711 -1835322135 22061
  </code></pre>
  <p>I don't see what's causing this problem since the first few numbers are right.
  (I know my code looks kinda spaghetti and I'm open to any advice :D)</p>