[#BloombergLP-bslfmt-format_to_n-0a] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslfmt.adoc[bslfmt]::format_to_n :relfileprefix: ../../ :mrdocs: Format `args` per `fmtStr` into `out`, writing at most `maxNumChars` characters. == Synopsis Declared in `<bslfmt_format_imp.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_OUT, class... t_ARGS> format_to_n_result<t_OUT> format_to_n( t_OUT out, bsl::iterator_traits<t_OUT>::difference_type maxNumChars, xref:BloombergLP/bslfmt/wformat_string.adoc[bslfmt::wformat_string<t_ARGS...>] fmtStr, t_ARGS const&... args); ---- == Description Format the specified `args` according to the specification given by the specified `fmtStr`, and write at most the specified `maxNumChars` characters of the result of this operation into the output iterator referenced by the specified `out` parameter. Return a `format_to_n_result` object whose `size` member holds the number of characters that would have been written to `out` were such writing not truncated, and whose `out` member holds an iterator one past the end of the output range. In the event of an error the exception `format_error` is thrown. Behavior is undefined if `out` does not point to a valid output iterator. [.small]#Created with https://www.mrdocs.com[MrDocs]#