C++23 print Header

Last Updated : 6 Mar, 2026

<print> header introduces a set of functions aimed at simplifying and enhancing the way developers handle output formatting in C++. These functions allow the use of the Unicode character set. The <print> header file defines the following two functions:

  1. print()
  2. println()

Note: This code requires C++23. Ensure your compiler is up to date and configured with the -std=c++23 flag to use the <print> library.

print()

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:

print (" {formatted_string}{} .... ", arguments...);

Parameters:

  • formatted_string: The string to be printed.
  • arguments: Lists of arguments that are to be printed

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.

C++
#include <iostream>
#include <print>
using namespace std;

int main()
{
    int a = 10;
    print("The value of argument: {}", a);
    print("Hello World");

    return 0;
}

Output:

The value of argument: 10Hello World

Notice that the "Hello World" gets printed right after the first statement.

println()

The println() function is also used to print the formatted string to the standard output stream but this function additionally prints the new line character ('\n') at the end of the output.

Syntax:

println(" {formatted_string} ", arguments...);

Parameters:

  • formatted_string: The string to be printed.
  • arguments: Lists of arguments that are to be printed
C++
#include <iostream>
#include <print> // Requires C++23 support
using namespace std;

int main()
{
    int a = 10;
    println("The value of argument: {}", a); 
    
    println("The quick brown fox jumps over the lazy dog.");

    return 0;
}

Output

The value of argument: 10 The quick brown fox jumps over the lazy dog

Comment