Issue when copying blocks of memory using memcpy : <p>In my following code, I made <code>buffer</code> as a 2D array created using <code>malloc(r * c * sizeof(double*));</code>. I want to copy the first 12 elements of <code>buffer</code> (i.e. the first 4 rows) into the second one <code>temp</code> using <code>memcpy</code>.</p>

<pre><code>double *buffer = malloc(10 * 3 * sizeof(double*));
double *temp = malloc(4 * 3 * sizeof(double*));

    for (int i = 0; i &lt; 4; ++i) {
        memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double));
    }
</code></pre>

<p>I get this error:</p>

<pre><code>memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>

<p>Can someone tell me why?</p>

<p>Thank you in advance.</p>
