What is the most efficient way to copy an int array in a C object?

What is the most efficient way to copy an array of 1000 integers from one array to another in a C object?

This will work on the iphone within some drawing code, so its important as efficiently as possible.

Thank.

+3
source share
2 answers

If the issue is performance-related, I assume this is a C array from int. If so, you can use memcpy ().

For instance:

int copyOfArr[4], arr[4] = {0,1,2,3};

memcpy(copyOfArr, arr, sizeof(arr));

Hope this helps.

+3
source

C, memcpy . NSArray, "copy".

+2

Source: https://habr.com/ru/post/1778523/


All Articles