-->
Page 1 of 1

How to pass data destined to console to a char array in Ardu

PostPosted: Sat May 16, 2020 12:50 pm
by DarioG
In a sketch that uses RTC on Arduino I have the following pieces of code:
Code: Select all// print time to Serial
void printTime(time_t t){
  printI00(hour(t), ':');
  printI00(minute(t), ':');
  printI00(second(t), ' ');
}

// print date to Serial
void printDate(time_t t){
  printI00(day(t), 0);
  Serial << monthShortStr(month(t)) << _DEC(year(t));
}


And with this print the RTC reading on the console:
Code: Select allvoid printDateTime(time_t t) {
  printDate(t);
  Serial << ' ';
  printTime(t);
}


How can I do so that I send to the console is also stored in a char array?
Code: Select allchar bufferMSGtoClient[100];