我有BYTE指针.例如,此BYTE数组的长度为10.如何从3位BYTE数组中读取4个字节?
现在我这样做了
BYTE *source = "1234567890\0";
BYTE* tmp = new BYTE[4+1]();
for(int i=0; i<4; i++)
{
tmp[i] = source[i+3];
}
Run Code Online (Sandbox Code Playgroud) 我试图为10个字节分配内存
BYTE* tmp;
tmp = new BYTE[10];
//or tmp = (BYTE*)malloc(10*sizeof(BYTE));
Run Code Online (Sandbox Code Playgroud)
但是在新的或malloc操作长度*tmp超过10之后(即'\ 0'char不在tmp数组中的10位)
为什么?