Concatenate 5 string at once

@AWOL:

legal C?

Yes. Everything he posted was legal C and legal C++ (in bits and pieces). He just didn't post everything. I mean, really!

From the original post:

char StringFinal[40];

void setup()
{
    Serial.begin(9600);
}

//CONCATENATE 5 STRINGS
// Good program design would not use a global variable, but might use a static array
// inside the function or some such thing.  (Maybe pass the array name and size to
// the function and use strncat or some such thing.)
// Actually, I can't imagine that I would ever need a function that
// did nothing more than put five "strings" into an array.
//
// Oh, well...
//
// But as "proof of concept" I'll just use the original, exactly as in
// the first post.
//
// davekw7x
//
char *concatena5(char *string1, char *string2, char *string3, char *string4, char *string5)
{
     StringFinal[0]='\0';
     strcat(StringFinal, string1);  
     strcat(StringFinal, string2);
     strcat(StringFinal, string3);
     strcat(StringFinal, string4);
     strcat(StringFinal, string5);
     return StringFinal;
}

void Escreve_Serial(char *sTexto)
{   
     Serial.println(sTexto);
}
void loop()
{
    char * sHH;
    char * sMM;
    char * sSS;

    sHH="21";
    sMM="43";
    sSS="00";
    Escreve_Serial(concatena5(sHH,":",sMM,":",sSS));
    while (1)
        ;
}

Output:


21:43:00


Regards,

Dave