title: copy a Matrix into another by memcpy in C
body: <p>I want to write a function to copy a two matrices into one matrix by use of memcpy. It is like C = [A; B] in Matlab. Because, I want to use this function for all the type of data, which means integer and float matrices, I used void pointer.</p>
  
  <p>the code is:</p>
  
  <pre><code>void Repmatrix(void *M3, void *M1, int R1, int C1, void *M2, int R2, int C2, size_t t)
  {
      if (RC == 'R')
      {
          int i;
          for (i = 0; i &lt; R1*C1; i++)
          {
              memcpy(M3+i, M1+i, t);
  
          }
          for (j = 0; j &lt; R1*C1; j++)
          {
              memcpy(M3+i+j, M1+j, t);
  
          }
      }
  }
  </code></pre>
  
  <p>Any help and suggestion is appreciated.</p>
  
  <p>To clarify it the inputs are:</p>
  
  <pre><code>M1 = [
  1 2
  3 4]
  M2 = [
  5 6
  7 8]
  </code></pre>
  
  <p>the output should be:</p>
  
  <pre><code>M3 = [
  1 2
  3 4
  5 6
  7 8]
  </code></pre>