[#absl-SNPrintF] = xref:absl.adoc[absl]::SNPrintF :relfileprefix: ../ :mrdocs: Writes to a sized buffer given a format string and zero or more arguments. == Synopsis Declared in `<absl/strings/str_format.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename... Args> int SNPrintF( char* output, std::size_t size, xref:absl/FormatSpec.adoc[FormatSpec<Args...>] const& format, Args const&... args); ---- == Description This function is functionally equivalent to `std::snprintf()` (and type‐safe); prefer `absl::SNPrintF()` over `std::snprintf()`. In particular, a successful call to `absl::SNPrintF()` writes at most `size` bytes of the formatted output to `output`, including a NUL‐terminator, and returns the number of bytes that would have been written if truncation did not occur. In the event of an error, a negative value is returned and `errno` is set. Example: std::string_view s = "Ulaanbaatar"; char output[128]; absl::SNPrintF(output, sizeof(output), "The capital of Mongolia is %s", s); Post‐condition: output == "The capital of Mongolia is Ulaanbaatar" == Return Value The number of bytes that would have been written, or a negative value on error. == Parameters [cols="1,4"] |=== | Name| Description | *output* | The buffer to write to. | *size* | The size of the buffer, in bytes. | *format* | The format string. | *args* | The arguments substituted into the format string. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#