title: How to make a copy of a byte array in c code?
body: <p>I have the address of the first char in my byte array, and it's size:
   const char *rawImageBytes, int size</p>
  
  <p>And I want to copy the content to a different byte array. and then modify that one a bit.
  This is whay I am doing now: </p>
  
  <pre><code>LOGI("FrameReceived will reach here 1");
  modifiedRawImageBytes = rawImageBytes;
  jint sizeWH = width * height;
  jint quarter = sizeWH/4;
  jint v0 = sizeWH + quarter;
  for (int u = sizeWH, v = v0, o = sizeWH; u &lt; v0; u++, v++, o += 2) {
          modifiedRawImageBytes[o] = rawImageBytes[v]; // For NV21, V first
          modifiedRawImageBytes[o + 1] = rawImageBytes[u]; // For NV21, U second
  }
  </code></pre>
  
  <p>But I don't get the correct colours, as if I would to this in Java, instead of c++.
  And I am assuming this happens, because I just do <code>modifiedRawImageBytes = rawImageBytes;</code> instead of actually copying the whole byte array, so that it can start in memory from another address pointer.
  A bit of a beginner with c, so I'm lost at this, can someone help me understand what is done wrong?
  PS: I am assuming that, because even if I send the rawImageBytes and not the modifiedRawImageBytes, it will still be modified</p>