我學習,我想知道的最佳方式是如何做到以下幾點陣列複製,考慮以下代碼:將字節複製到字節數組?
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++ ** .. –