Best way to trim null elements from end of char[] ?

I assemble a string of keys and values for transmission over a radio network. I declare and initialise:

char sendbuffer[50] = {0};

and then append data using strcat() - for example

  strcpy(sendbuffer, "test1%MILLIS:");
  sprintf(intbuf, "%lu", millis());
  strcat(sendbuffer, intbuf);
  strcat(sendbuffer, ";");

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.

Cheers,

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".

You don't show how the filled character array is used so we don't know where the problem is.

You know about the strlen() function?

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).