我学习,我想知道的最佳方式是如何做到以下几点阵列复制,考虑以下代码:将字节复制到字节数组?
void Cast1LineSpell(UINT Serial, char *chant)
{
byte packet[] = { 0x0F, 0x03,
(Serial >> 24) & 0xFF, (Serial >> 16) & 0xFF,(Serial >> 8) & 0xFF, Serial & 0xFF,
0x9A, 0x92, 0x00, 0x00, 0x00, 0x1A };
byte prepareSpell[2] = { 0x4D, 0x01 };
byte chant_length = sizeof(chant)/sizeof(chant[0]);
byte chant_name[] = { 0x4E, chant_length, }; // <= how can i put the bytes in chant* into the rest of this array, and then append bytes 0x00 and 0x4E on to the end of it?
}
我怎样才能把那些的*chant
里面的字节,然后把它们到chant[]
的末尾,然后在其末尾添加字节0x00
和0x4E
?
任何人都可以提供解决方案吗? 备受赞赏。
应该如何运作的?你期望输出什么? –
我想chant []输出0x4D,0x01,chant_length,无论是在* chant,0x00,0x4E – Dean
你最好使用像'std :: vector'这样的容器,因为它被标记了** C++ ** .. –