在指针中保存确定的位置

save determinate positions in pointer

本文关键字:位置 保存 指针      更新时间:2023-10-16

我需要在uint8_t指针确定数组的位置。

示例:

uint8_t array[40] = {1,2,3,etc...}

uint8_t *pointer = array[5] - [25]。保存在指针位置仅5到25之间。我需要C 语言。

感谢社区!

// Indices for the desired range of values.
constexpr std::size_t first = 5;
constexpr std::size_t last = 15;
// Create a new array with the appropriate size.
uint8_t array2[last - first];
// Copy the data to the array.
std::copy(array + first, array + last, std::begin(array2));