I am coding on the Arduino platform and I am trying to write something that will concatenate/append byte arrays in C.
byte a[] = {a1, ..., an};
byte b[] = {b1, ..., bm};
byte c[] = a + b; // equivalent to {a1, ..., an, b1, ..., bm}
What is the best way to get the above result?
I tried searching online, however I have not had much luck. I saw another answer on SO highlighting the steps needed in order to do this however I could not follow them. They also say that there are libraries that deal with this kind of thing, however as I am on Arduino I am unsure whether or not these are totally available to me.
I understand there needs to be some sort of memory manipulation in order for this to work however I am new to these kinds of low level manipulations so they do not make too much sense to me. I have experience in higher languages (C#, Java and some C++).
I should also add: Can the same technique work for:
byte a[] = {a1, ..., an};
byte b[] = {b1, ..., bm};
a = a + b
byteis acharsized equivalent,byte c[sizeof(a) + sizeof(b];and twomemcpycalls would do it if that really is howaandbare declared.ais initially sized to accommodate its data and space for appended data And amemcpy-type operation is still involved sooner or later. Regardless, the syntax you're using is definitely not congruent with the C language.