print() Function in C++
The print() function is used to print the formatted string to the output stream. This function is similar to the old C printf() function in the way it shows output but its internal implementation is based on the modern C++ components.
Syntax of print()
print (" {formatted_string}{} .... ", arguments...);
where,
- formatted_string: The string to be printed.
- arguments: Lists of arguments that are to be printed
How to print arguments in formatted_string?
Printing formatted string is different from the old printf() function. Here, arguments are denoted by curly brackets {} at the place where it we want the argument to be printed.
Example: Printing Hello World
C++
// C++ program to print hello world using print satement #include <iostream> #include <print> using namespace std; int main() { // new function print( "Hello World" ); return 0; } |
Output
Hello World
C++23 Header
C++ has long been a powerful language, known for its versatility and performance. With each new standard release, the language evolves, introducing features that enhance developer productivity and code readability. One of these additions of the C++ 23 standard is the introduction of <print> header to enhance the output capability of language.