title: how to merge two dimensional arrays in c++?
body: <p>I want to merge the following two 2D arrays <code>A</code> and <code>B</code> into one 2D array <code>C</code> using C++ code. I tried to fill the array <code>C</code> with array <code>B</code> first and array <code>A</code> afterwards, but it's not working.</p>
  
  <pre><code>int A[3][2]={{1,2},
               {4,5},
               {7,8}};
  
  int B[3][1]={{0},
               {4,},
               {7,}};
  
  int C[3][3] =
          { { 0, 1 ,2},
           { 4, 4, 5},
            {7 ,7 ,8}}
  </code></pre>
  
  <p>The code I am using is:</p>
  
  <pre><code>// merge part
  for(int i = 0; i &lt;3; i++)
      {
          for(int j = 0; j &lt; 3; j++)
          {
              if(i&lt;1)
              {
                  C[i][j] = B[i][j];
              }
              else
              {
                  C[i][j] =A[i-1][j] ;
              }
          }
      }
      cout&lt;&lt;"\n\n\C: "&lt;&lt;endl;
  
      for(int i = 0; i &lt; 3; i++)
      {
          for(int j = 0; j &lt; 3; j++)
          {
              cout&lt;&lt;C[i][j];
          }
      }
  </code></pre>