std::println

Header: <print>

Format args according to the format string fmt with appended ‘\n’ (which means that each output ends with a new-line), and print the result to a stream.

# Declarations

template< class... Args >
void println( std::format_string<Args...> fmt, Args&&... args );

(since C++23)

template< class... Args >
void println( std::FILE* stream,
std::format_string<Args...> fmt, Args&&... args );

(since C++23)

void println();

(since C++26)

void println( std::FILE* stream );

(since C++26)

# Parameters

# Notes

Although overloads (3,4) are added in C++26, all known implementations make them available in C++23 mode.

# Example

#include <print>
 
int main()
{
    // Each call to std::println ends with new-line
    std::println("Please"); // overload (1)
    std::println("enter"); // (1)
 
    std::print("pass");
    std::print("word");
 
    std::println(); // (3); valid since C++26; same effect as std::print("\n"); 
}

# See also