title: C++ - How to use memmove for items in 2D array?
body: <p>I have the following 2D array:</p>
  
  <pre><code>float accumulator[MAX_CHANNELS][2*MAX_FRAME_LENGTH];
  </code></pre>
  
  <p>and I keep moving the blocks of memory in my code for every channel like this:</p>
  
  <pre><code>for (int channel = 0; channel &lt; nChannels; channel++) {
      memmove(accumulator[channel], accumulator[channel] + stepSize, fftFrameSize * 2 * sizeof(float));
  }
  </code></pre>
  
  <p>However, this gives me wrong results and I don't understand why. What is wrong with the <code>memmove</code> call that I am using?</p>
  
  <p>Alternatively, I tried using the following 1D arrays (1 for each channel)  instead and got correct results:</p>
  
  <pre><code>float accumulator1[2*MAX_FRAME_LENGTH];
  float accumulator2[2*MAX_FRAME_LENGTH];
  
  memmove(accumulator1, accumulator1 + stepSize, fftFrameSize * 2 * sizeof(float));
  memmove(accumulator2, accumulator2 + stepSize, fftFrameSize * 2 * sizeof(float));
  </code></pre>