You can use memcpy()
to copy unsigned char
s from one array to another:
void concatenate() {
unsigned char part1[] = { 0x40, 0x34 };
unsigned char flag[2] = { 0x4f, 0x4e };
unsigned char part2[] = { 0x01, 0x40 };
unsigned char output[sizeof part1 + sizeof flag + sizeof part2];
memcpy(output + 0, part1);
memcpy(output + sizeof part1, flag);
memcpy(output + sizeof part1 + sizeof flag, part2);
}
This is just one options, there are more ways to do it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…