Marc
Marc

Reputation: 73

std::copy equivalent in C

I have some code in C++ that use std::copy in these lines

std::copy(array1, array1 + 4, arrayV + i);
std::copy(array2, array2 + 4, arrayV + i + 4);

inside a unroll loop. All of arrays are uint8_t*. How can I transform these lines for equivalent code in C that will produce the same result?

Upvotes: 0

Views: 557

Answers (1)

Aykhan Hagverdili
Aykhan Hagverdili

Reputation: 29955

You can use memcpy:

instead of

std::copy(array2, array2 + 4, arrayV + i + 4);

you do

memcpy(arrayV + i + 4, array2, sizeof(*array2) * 4);

If the memory blocks may overlap, you may use memove.

Upvotes: 2

Related Questions