string formating c++ code example
Example 1: format string cpp
#include <iostream>
#include <format>
int main() {
std::cout << std::format("Hello {}!\n", "world");
}
Example 2: c++ formatting
cout << setw(10) << "ten" << "four" << "four" << '\n';
// Display ten fourfour
cout << setfill('-') << setw(80) << "-" << '\n';
// Displays 80 "-"