Difficulty appending a a local buffer value with a string

Please excuse my terminology if not perfect.

I'm trying learn how to combine a string value with a local buffer containing time and date.
I can't seem to get the syntax correct or find an example of this.

So I'll have a result like: The time is: 12:49 04/13/2013. My project will put different values in String mess1 depending on what's happening.

My code
1
2
3
4
5
char buf1[20];
String mess1 = "The time is:";
sprintf(buf1, "%02d:%02d  %02d/%02d/%4d", hour(), minute(), month(), day(), year());
//mySerial.println(buf1);   // operates perfect
mySerial.println(mess1 buf1);  // Does not compile - error: expected `)' before 'buf1' 


I have also tried a comma between (mess1, buf1), no help.

Any suggestions appreciated.
Last edited on
What is the type of the argument(s) that println() accepts?

Does type String have a method that can append a char array to its value?
¿what is a `String'?
It may have some method to concatenate, by instance you can use `+' with `std::string'
Last edited on
I hope this answers your question. I'm not sure of the limitations of println.
I'm using this code with an Arduino.

But I do know the println does work with a string like "The time is:" and it does work with a local buffer containing my time & date as follows:
"%02d:%02d %02d/%02d/%4d", hour(), minute(), month(), day(), year().

If I add my text in the buffer like this, it does also work perfect:

"The time is: %02d:%02d %02d/%02d/%4d", hour(), minute(), month(), day(), year()

Does type String have a method that can append a char array to its value?
I'll have to research this.
Last edited on
Topic archived. No new replies allowed.