absl::PrintF

Writes to stdout given a format string and zero or more arguments.

Synopsis

Declared in <absl/strings/str_format.h>

template<typename... Args>
int
PrintF(
    FormatSpec<Args...> const& format,
    Args const&... args);

Description

This function is functionally equivalent to std::printf() (and type-safe); prefer absl::PrintF() over std::printf().

Example:

std::string_view s = "Ulaanbaatar"; absl::PrintF("The capital of Mongolia is %s", s);

Outputs: "The capital of Mongolia is Ulaanbaatar"

Return Value

The number of characters written, or a negative value on error.

Parameters

NameDescription
formatThe format string.
argsThe arguments substituted into the format string.