title: C swapping elements in two dimensional array
body: <p>I wrote swap function in C.</p>
  
  <pre><code>void swapping(int dim, int size, void *n1, void *n2) {
     int s = dim * size;
     char a[s];
     memcpy(a, n2, s);
     memcpy(n2, n1, s);
     memcpy(n1, a, s);
  }
  </code></pre>
  
  <p>I have let's say: </p>
  
  <pre><code>double t[10][3];
  // write some value to array
  </code></pre>
  
  <p>when I swapping two elements:</p>
  
  <pre><code>swapping(3, sizeof(double), &amp;t[1], &amp;t[2]);
  </code></pre>
  
  <p>and <code>printf</code> them on the console. I got correct value not on every place.
  For example: with</p>
  
  <pre><code>t[1][3] = { 123.0000, 324.1231, 923.9992};
  </code></pre>
  
  <p>I got:</p>
  
  <pre><code>123.0000120, 324.1231029, 923.999350
  </code></pre>
  
  <p>Where is the problem?</p>
  
  <p>P.S. I used <code>void *</code> because I want to use this function with different types.</p>