c++ string format code example
Example 1: sprintf
char myConcatenation[80];
char myCharArray[16]="A variable name";
int myInt=5;
sprintf(myConcatenation,"%s = %i",myCharArray,myInt);
Serial.println(myConcatenation);
Example 2: format string cpp
#include <iostream>
#include <format>
int main() {
std::cout << std::format("Hello {}!\n", "world");
}
Example 3: c++ formatting
cout << setw(10) << "ten" << "four" << "four" << '\n';
// Display ten fourfour
cout << setfill('-') << setw(80) << "-" << '\n';
// Displays 80 "-"