Closed msh2050 closed 7 years ago
void setup() { Serial.begin(9600);
char buffer = "H:xx M:xx S:xx"; // something that will hold the modified string. char buffer[15]; works too but make sure it has enough room to hold all the visible characters plus the (carriage return / new line character) '\n'.
int hours = 12; int minutes = 35; int seconds = 40; sprintf(buffer, "H:%02d M:%02d S:%02d", hours, minutes, seconds); // %02d means you want to occupy 2 spaces with the character '0'. ie. H:00. "d" means the variable you are passing it will be a number.
Serial.println(buffer); // this should print out H:12 M:35 S:40 }
thanks alot 👍
it is noted in the examples :
please any example or hint