有没有一种方法可以使用memcpy(或类似函数)从一个循环数组复制到另一个循环数组,但带有偏移量?我可以使用循环实现,但我想更快地实现它。
显然,内存中没有“循环”这个概念,但我希望你能理解我的意思。
谢谢大家。
这就是我想要实现的,但不想使用for循环。
uint8_t array1[SIZE];
uint8_t array2[SIZE];
uint8_t offset = SOME_OFFSET;
uint8_t offsetAdj;
for (uint8_t index = 0; index < SIZE; index++)
{
offsetAdj = offset + index;
if (offsetAdj >= SIZE)
offsetAdj -= SIZE;
array2[offsetAdj] = array1[index];
}
memcpy
调用。 - Konrad Rudolph