什么是复制目标C int数组的最有效方法是什么?数组、最有效、目标、方法

2023-09-11 06:21:27 作者:梨涡浅浅

什么是从一个阵列复制1000整数数组到另一个目标C最有效的方法是什么?

What is the most efficient way to copy an array of 1000 ints from one array to another in objective C?

这将在一定范围内绘图code iPhone的运行,所以它是尽可能高效重要的。

This will be running on an iphone within some drawing code so its important to be as efficient as possible.

感谢。

推荐答案

如果值得关注的是效率,我假定这是整数的一个C数组。如果是这样,你可以使用的memcpy()。

if the concern is efficiency, I'm assuming this is a C array of ints. If so, you can use memcpy().

例如:

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

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

希望有所帮助。

Hope that helps.