开发者

How to read some bytes from BYTE*

开发者 https://www.devze.com 2022-12-23 05:11 出处:网络
I have BYTE pointer. For example the length of this BYTE array is 10. How can I read 4 by开发者_StackOverflow中文版tes from 3 position BYTE array?

I have BYTE pointer. For example the length of this BYTE array is 10. How can I read 4 by开发者_StackOverflow中文版tes from 3 position BYTE array?

Now I doing it so

BYTE *source = "1234567890\0";
BYTE* tmp = new BYTE[4+1]();
for(int i=0; i<4; i++)
{
tmp[i] = source[i+3];
}


1)

 std::vector<BYTE> tmp1(source + 3, source + 7);

2)

BYTE tmp[5];
std::copy(source + 3, source + 7, tmp);

3)

BYTE tmp2[5];
memcpy(tmp, source + 3, 4 * sizeof(source[0]));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号