Ultimately, sendbuffer[] ends up with an unknown number of null (0) elements following the end of the message. What's the best way to remove those elements, or create a new char[] only including the data. Basically, I want to avoid sending null characters to the function that deals with the radio transmission, as these chars simply waste time and power.
jmusther:
Ultimately, sendbuffer[] ends up with an unknown number of null (0) elements following the end of the message. What's the best way to remove those elements, or create a new char[] only including the data. Basically, I want to avoid sending null characters to the function that deals with the radio transmission, as these chars simply waste time and power.
It's not clear to me why the extra nulls should cause any troubles with your functions. Surely they should just process the sendbuffer until they encounter the first null and be done.
I can't see any scheme for coping to a new buffer (which has just one null) doing anything other than to "waste time and power".
The NULLs are in the array to tell functions that expect strings to stop processing when they encounter a NULL.
If the code you have is not dealing with strings, but is dealing with char arrays, then YOU need to write the code better, telling it how many characters to deal with (not the whole array).