Ashton
1
Please excuse my terminology if not perfect.
I'm trying 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.
char buf1[20];
String mess1 = "Stored text";
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'
Any suggestions appreciated.
Ashton
3
I have tried adding a comma between elements as below, that also causes compile errors (many more).
mySerial.println(mess1, buf1);
This method doesn't include the buf1 in the result:
mySerial.println(mess1),(buf1);
Arrch
4
mySerial.print(mess1)
mySerial.println(buf1)
Ashton
5
Ok
I tested this:
mySerial.println(mess1);
mySerial.println(buf1);
But it produces a CR and LF, so the result is:
"Stored text
13:30 04/13/2013"
I need this: "Stored text 13:30 04/13/2013"
print() not println() which adds a linefeed
See Arrch's example.
Ashton
7
Oh, Yes I see.
I corrected to the print() and it worked great.
Thanks.