Update 2023:
The idiomatic way to print to the console from c++23 is supposed to be with std::print
, which uses {}
placeholders in the format string syntax (see below):
#include <print>int main(){ std::print("{}, {} !", "Hello", "world");}
However as of now, the compilers support for it is very poor.
Meanwhile we can use the {fmt} library for a similar API.
Note that the c++ standard is actually based (mostly) on a subset of {fmt}.
See more about it here: What are the differences between libfmt and std::format?.
For more info about the format string syntax see here: {fmt} Format String Syntax.
Working example:
#include <fmt/core.h>int main(){ fmt::print("{}, {} !", "Hello", "world");}