开发者

How to read some bytes from BYTE*

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜