memcpy with startIndex?

后端 未结 9 1254
星月不相逢
星月不相逢 2020-12-24 11:31

I wish to copy content of specific length from one buffer to another from a specific starting point. I checked memcpy() but it takes only the length of content

9条回答
  •  自闭症患者
    2020-12-24 12:01

    Simply increase your pointer to your start index.

    Example

    const unsigned char * src = reinterpret_cast(your source);
    unsigned char * dest = reinterpret_cast(your dest);
    memcpy(dest, src + offset, len);
    

    What about using STL collections to avoid memory access errors?

提交回复
热议问题