How to combine byte arrays for accepts a variable number of arguments(variadic function) in c?
typedef struct {
unsigned char *data;
int length;
} bytes;
// Problem in here how to combine byte arrays
// for accepts a variable number of arguments
bytes bytesConcat(bytes fmt, ...) {
return b1 + b2 + ...b(n)
}
static unsigned char src1[] = { 1,2 };
static unsigned char src2[] = { 3,4 };
void main() {
bytes b1, b2;
b1.data = src1;
b1.length = sizeof(src1);
b2.data = src2;
b2.length = sizeof(src2);
// call byteConcat with passing two arguments
// result1 expected is 1,2,3,4
bytes result1 = bytesConcat(b1, b2);
}
Thanks in advance