Skip to content

std::print (C++23) ​

TL;DR ​

Writes formatted strings straight to stdout — std::format and std::cout rolled into one, the new way to write Hello World in C++23.

#include <print>

Core API Cheat Sheet ​

OperationSignatureDescription
Output to stdoutvoid print(format_string, args...)Formats and writes to standard output
Output with newlinevoid println(format_string, args...)Automatically appends a newline
Blank linevoid println()Outputs just a newline character
Output to filevoid print(FILE* f, format_string, args...)Writes to a given C file stream
Output to file with newlinevoid println(FILE* f, format_string, args...)Newline version
Output to streamvoid vprint_unicode(std::ostream&, std::format_args)Writes to a C++ stream

Minimal Example ​

C++
// Standard: C++23
#include <print>

int main() {
    std::print("Hello, {}!\n", "world");
    std::println("value = {}", 42);
    std::println("{:>10.2f}", 3.14159); //       3.14
    std::println();                      // blank line
}

Embedded Applicability: Low ​

  • Depends on stdout and the filesystem abstraction layer; bare-metal environments usually have no standard output
  • A good fit for log output in embedded Linux host-side tools and test frameworks
  • The formatting engine carries significant Flash overhead; not recommended for extremely resource-constrained devices
  • You can fall back to fmt::print from the {fmt} library, available since C++11

Compiler Support ​

GCCClangMSVC
141819.34

See Also ​


Some content is adapted from cppreference.com, used under the CC-BY-SA 4.0 license

pdf-latest-4-g85128cc · 85128cc · 2026-10-05