I have BYTE pointer. For example the length of this BYTE array is 10. How can I read 4 bytes from 3 position BYTE array?
我有字节指针。例如,这个字节数组的长度是10。如何从3位字节数组中读取4个字节?
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 个解决方案
#1
5
1)
1)
std::vector<BYTE> tmp1(source + 3, source + 7);
2)
2)
BYTE tmp[5];
std::copy(source + 3, source + 7, tmp);
3)
3)
BYTE tmp2[5];
memcpy(tmp, source + 3, 4 * sizeof(source[0]));
#1
5
1)
1)
std::vector<BYTE> tmp1(source + 3, source + 7);
2)
2)
BYTE tmp[5];
std::copy(source + 3, source + 7, tmp);
3)
3)
BYTE tmp2[5];
memcpy(tmp, source + 3, 4 * sizeof(source[0]));