absl::FPrintF

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

Synopsis

Declared in <absl/strings/str_format.h>

template<typename... Args>
int
FPrintF(
    FILE* output,
    FormatSpec<Args...> const& format,
    Args const&... args);

Description

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

Example:

std::string_view s = "Ulaanbaatar"; absl::FPrintF(stdout, "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
outputThe file to write to.
formatThe format string.
argsThe arguments substituted into the format string.