title: how to set 2d dynamic array with specific values in c++
body: <p>I create a 2D dynamic array (ary), and initialize all the element to -1 ,,, then i want to set array element with some values,, but it dose't work</p>
  
  <pre><code>int rowCount,t;
  
  t=4; rowCount = t/3 + (t % 3 != 0);
  
  int** ary = new int*[rowCount];
  for(int i = 0; i &lt; rowCount; ++i)
      ary[i] = new int[t];
  
  
  for (int n = 0; n &lt; rowCount*t; n++)
    *((int*)ary + t) = -1;
  
  for(int m=0;m&lt;rowCount;m++)
     for(int h=0;h&lt;t;h++)
  ary[m][h]=a[h];  // a is predefined array  
  </code></pre>