summaryrefslogtreecommitdiff
path: root/devdocs/c/io%2Fvfwprintf.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/io%2Fvfwprintf.html
new repository
Diffstat (limited to 'devdocs/c/io%2Fvfwprintf.html')
-rw-r--r--devdocs/c/io%2Fvfwprintf.html227
1 files changed, 227 insertions, 0 deletions
diff --git a/devdocs/c/io%2Fvfwprintf.html b/devdocs/c/io%2Fvfwprintf.html
new file mode 100644
index 00000000..4fbbfa0c
--- /dev/null
+++ b/devdocs/c/io%2Fvfwprintf.html
@@ -0,0 +1,227 @@
+ <h1 id="firstHeading" class="firstHeading">vwprintf, vfwprintf, vswprintf, vwprintf_s, vfwprintf_s, vswprintf_s, vsnwprintf_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;wchar.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl-rev-aux"> <td></td> <td rowspan="3">(1)</td> <td></td> </tr> <tr class="t-dcl t-since-c95 t-until-c99"> <td> <pre data-language="c">int vwprintf( const wchar_t *format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> <br><span class="t-mark-rev t-until-c99">(until C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">int vwprintf( const wchar_t *restrict format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl-rev-aux"> <td></td> <td rowspan="3">(2)</td> <td></td> </tr> <tr class="t-dcl t-since-c95 t-until-c99"> <td> <pre data-language="c">int vfwprintf( FILE* stream, const wchar_t *format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> <br><span class="t-mark-rev t-until-c99">(until C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">int vfwprintf( FILE *restrict stream,
+ const wchar_t *restrict format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl-rev-aux"> <td></td> <td rowspan="3">(3)</td> <td></td> </tr> <tr class="t-dcl t-since-c95 t-until-c99"> <td> <pre data-language="c">int vswprintf( wchar_t *buffer, size_t bufsz,
+ const wchar_t *format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> <br><span class="t-mark-rev t-until-c99">(until C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">int vswprintf( wchar_t *restrict buffer, size_t bufsz,
+ const wchar_t *restrict format, va_list vlist );</pre>
+</td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl"> <td> <pre data-language="c">int vwprintf_s( const wchar_t *restrict format, va_list vlist);</pre>
+</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> <tr class="t-dcl"> <td> <pre data-language="c">int vfwprintf_s( FILE * restrict stream,
+ const wchar_t *restrict format, va_list vlist);</pre>
+</td> <td> (5) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> <tr class="t-dcl"> <td> <pre data-language="c">int vswprintf_s( wchar_t *restrict buffer, rsize_t bufsz,
+ const wchar_t * restrict format, va_list vlist);</pre>
+</td> <td> (6) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> <tr class="t-dcl"> <td> <pre data-language="c">int vsnwprintf_s( wchar_t *restrict buffer, rsize_t bufsz,
+ const wchar_t *restrict format, va_list vlist);</pre>
+</td> <td> (7) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <p>Loads the data from locations, defined by <code>vlist</code>, converts them to wide string equivalents and writes the results to a variety of sinks.</p>
+<div class="t-li1">
+<span class="t-li">1)</span> Writes the results to <code><a href="std_streams" title="c/io/std streams">stdout</a></code>.</div> <div class="t-li1">
+<span class="t-li">2)</span> Writes the results to a file stream <code>stream</code>.</div> <div class="t-li1">
+<span class="t-li">3)</span> Writes the results to a wide string <code>buffer</code>. At most <code>bufsz-1</code> wide characters are written followed by null wide character. The resulting wide character string will be terminated with a null wide character, unless <code>bufsz</code> is zero.</div> <div class="t-li1">
+<span class="t-li">4-6)</span> Same as <span class="t-v">(1-3)</span>, except that the following errors are detected at runtime and call the currently installed <a href="../error/set_constraint_handler_s" title="c/error/set constraint handler s">constraint handler</a> function: <ul>
+<li> the conversion specifier <code>%n</code> is present in <code>format</code> </li>
+<li> any of the arguments corresponding to <code>%s</code> is a null pointer </li>
+<li> <code>format</code> or <code>buffer</code> is a null pointer </li>
+<li> <code>bufsz</code> is zero or greater than <code>RSIZE_MAX/sizeof(wchar_t)</code> </li>
+<li> encoding errors occur in any of string and character conversion specifiers </li>
+<li> (for <code>vswprintf_s</code> only), the string to be stored in <code>buffer</code> (including the trailing wide null) would be exceed <code>bufsz</code>
+</li>
+</ul>
+</div> <div class="t-li1">
+<span class="t-li">7)</span> Same as <span class="t-v">(6)</span>, except it will truncate the result to fit within the array pointed to by <code>buffer</code>. As with all bounds-checked functions, <code>vwprintf_s</code> , <code>vfwprintf_s</code>, <code>vswprintf_s</code>, and <code>vsnwprintf_s</code> are only guaranteed to be available if <code>__STDC_LIB_EXT1__</code> is defined by the implementation and if the user defines <code>__STDC_WANT_LIB_EXT1__</code> to the integer constant <code>1</code> before including <a href="../io" title="c/io"><code>&lt;stdio.h&gt;</code></a>.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> stream </td> <td> - </td> <td> output wide stream to write to </td>
+</tr> <tr class="t-par"> <td> buffer </td> <td> - </td> <td> pointer to a wide string to write to </td>
+</tr> <tr class="t-par"> <td> bufsz </td> <td> - </td> <td> maximum number of wide characters to write </td>
+</tr> <tr class="t-par"> <td> format </td> <td> - </td> <td> pointer to a null-terminated wide string specifying how to interpret the data </td>
+</tr> <tr class="t-par"> <td> vlist </td> <td> - </td> <td> <a href="../language/variadic" title="c/language/variadic">variable argument list</a> containing the data to print. </td>
+</tr>
+</table> <p><br> The <b>format</b> string consists of ordinary wide characters (except <code>%</code>), which are copied unchanged into the output stream, and conversion specifications. Each conversion specification has the following format:</p>
+<ul>
+<li> introductory <code>%</code> character. </li>
+<li> <span class="t-mark">(optional)</span> one or more flags that modify the behavior of the conversion: </li>
+<ul>
+<li> <code>-</code>: the result of the conversion is left-justified within the field (by default it is right-justified). </li>
+<li> <code>+</code>: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative). </li>
+<li> <i>space</i>: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if <code>+</code> flag is present. </li>
+<li> <code>#</code>: <i>alternative form</i> of the conversion is performed. See the table below for exact effects otherwise the behavior is undefined. </li>
+<li> <code>0</code>: for integer and floating point number conversions, leading zeros are used to pad the field instead of <i>space</i> characters. For integer numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if <code>-</code> flag is present. </li>
+</ul>
+<li> <span class="t-mark">(optional)</span> integer value or <code>*</code> that specifies minimum field width. The result is padded with <i>space</i> characters (by default), if required, on the left when right-justified, or on the right if left-justified. In the case when <code>*</code> is used, the width is specified by an additional argument of type <code>int</code>, which appears before the argument to be converted and the argument supplying precision if one is supplied. If the value of the argument is negative, it results with the <code>-</code> flag specified and positive field width (Note: This is the minimum width: The value is never truncated.). </li>
+<ul>
+<li> <span class="t-mark">(optional)</span> <code>.</code> followed by integer number or <code>*</code>, or neither that specifies <i>precision</i> of the conversion. In the case when <code>*</code> is used, the <i>precision</i> is specified by an additional argument of type <code>int</code>, which appears before the argument to be converted, but after the argument supplying minimum field width if one is supplied. If the value of this argument is negative, it is ignored. If neither a number nor <code>*</code> is used, the precision is taken as zero. See the table below for exact effects of <i>precision</i>. </li>
+<li> <span class="t-mark">(optional)</span> <i>length modifier</i> that specifies the size of the argument (in combination with the conversion format specifier, it specifies the type of the corresponding argument). </li>
+<li> conversion format specifier. </li>
+</ul>
+</ul> <p>The following format specifiers are available:</p>
+<table class="wikitable"> <tr> <th rowspan="1">Conversion<br>Specifier </th> <th rowspan="1">Explanation </th> <th colspan="9">Expected<br>Argument Type </th>
+</tr> <tr> <th colspan="2">
+<b>Length<br>Modifier</b><b>→</b> </th> <th>
+<code>hh</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <th>
+<code>h</code> </th> <th>(none) </th> <th>
+<code>l</code> </th> <th>
+<code>ll</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <th>
+<code>j</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <th>
+<code>z</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <th>
+<code>t</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <th>
+<code>L</code> </th>
+</tr> <tr> <th>
+<code>%</code> </th> <td>Writes literal <code>%</code>. The full conversion specification must be <code>%%</code>. </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>c</code> </th> <td> Writes a <b>single character</b>. <p>The argument is first converted to <code>wchar_t</code> as if by calling <code><a href="../string/multibyte/btowc" title="c/string/multibyte/btowc">btowc</a></code>. If the <b>l</b> modifier is used, the <code>wint_t</code> argument is first converted to <code>wchar_t</code>.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td>
+<div><code>int</code></div> </td> <td>
+<div><code>wint_t</code></div> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>s</code> </th> <td> Writes a <b>character string</b> <p>The argument must be a pointer to the initial element of a character array containing a multibyte character sequence beginning in the initial shift state, which is converted to wide character array as if by a call to <code><a href="../string/multibyte/mbrtowc" title="c/string/multibyte/mbrtowc">mbrtowc</a></code> with zero-initialized conversion state. <i>Precision</i> specifies the maximum number of wide characters to be written. If <i>Precision</i> is not specified, writes every wide characters up to and not including the first null terminator. If the <b>l</b> specifier is used, the argument must be a pointer to the initial element of an array of <code>wchar_t</code>.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td>
+<div><code>char*</code></div> </td> <td>
+<div><code>wchar_t*</code></div> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>d</code><br><code>i</code> </th> <td> Converts a <b>signed integer</b> into decimal representation <i>[-]dddd</i>. <p><i>Precision</i> specifies the minimum number of digits to appear. The default precision is <code>1</code>.<br><br> If both the converted value and the precision are <code>​0​</code> the conversion results in no characters.<br><br></p>
+</td> <td rowspan="1">
+<div><code>signed char</code></div> </td> <td rowspan="1">
+<div><code>short</code></div> </td> <td rowspan="1">
+<div><code>int</code></div> </td> <td rowspan="1">
+<div><code>long</code></div> </td> <td rowspan="1">
+<div><code>long long</code></div> </td> <td rowspan="1">
+<div><code><a href="http://en.cppreference.com/w/c/types/integer"><span class="kw118">intmax_t</span></a></code></div> </td> <td rowspan="1">
+<div>signed <code><a href="http://en.cppreference.com/w/c/types/size_t"><span class="kw100">size_t</span></a></code>
+</div> </td> <td rowspan="1">
+<div><code><a href="http://en.cppreference.com/w/c/types/ptrdiff_t"><span class="kw101">ptrdiff_t</span></a></code></div> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>o</code> </th> <td> Converts an <b>unsigned integer</b> into octal representation <i>oooo</i>. <p><i>Precision</i> specifies the minimum number of digits to appear. The default precision is <code>1</code>. If both the converted value and the precision are <code>​0​</code> the conversion results in no characters. In the <i>alternative implementation</i> precision is increased if necessary, to write one leading zero. In that case if both the converted value and the precision are <code>​0​</code>, single <code>​0​</code> is written.</p>
+</td> <td rowspan="3">
+<div><code>unsigned char</code></div> </td> <td rowspan="3">
+<div><code>unsigned short</code></div> </td> <td rowspan="3">
+<div><code>unsigned int</code></div> </td> <td rowspan="3">
+<div><code>unsigned long</code></div> </td> <td rowspan="3">
+<div><code>unsigned long long</code></div> </td> <td rowspan="3">
+<div><code><a href="http://en.cppreference.com/w/c/types/integer"><span class="kw132">uintmax_t</span></a></code></div> </td> <td rowspan="3">
+<div><code><a href="http://en.cppreference.com/w/c/types/size_t"><span class="kw100">size_t</span></a></code></div> </td> <td rowspan="3">
+<div>unsigned version of <code><a href="http://en.cppreference.com/w/c/types/ptrdiff_t"><span class="kw101">ptrdiff_t</span></a></code>
+</div> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>x</code><br><code>X</code> </th> <td> Converts an <b>unsigned integer</b> into hexadecimal representation <i>hhhh</i>. <p>For the <code>x</code> conversion letters <code>abcdef</code> are used.<br> For the <code>X</code> conversion letters <code>ABCDEF</code> are used.<br> <i>Precision</i> specifies the minimum number of digits to appear. The default precision is <code>1</code>. If both the converted value and the precision are <code>​0​</code> the conversion results in no characters. In the <i>alternative implementation</i> <code>0x</code> or <code>0X</code> is prefixed to results if the converted value is nonzero.</p>
+</td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>u</code> </th> <td> Converts an <b>unsigned integer</b> into decimal representation <i>dddd</i>. <p><i>Precision</i> specifies the minimum number of digits to appear. The default precision is <code>1</code>. If both the converted value and the precision are <code>​0​</code> the conversion results in no characters.</p>
+</td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>f</code><br><code>F</code> </th> <td> Converts <b>floating-point number</b> to the decimal notation in the style <i>[-]ddd.ddd</i>. <p><i>Precision</i> specifies the exact number of digits to appear after the decimal point character. The default precision is <code>6</code>. In the <i>alternative implementation</i> decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td rowspan="4">
+<div><code>double</code></div> </td> <td rowspan="4">
+<div>
+<code>double</code><span class="t-mark-rev t-since-c99">(C99)</span>
+</div> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td rowspan="4">
+<div><code>long double</code></div> </td>
+</tr> <tr> <th>
+<code>e</code><br><code>E</code> </th> <td> Converts <b>floating-point number</b> to the decimal exponent notation. <p>For the <code>e</code> conversion style <i>[-]d.ddd</i><code>e</code><i>±dd</i> is used.<br> For the <code>E</code> conversion style <i>[-]d.ddd</i><code>E</code><i>±dd</i> is used.<br> The exponent contains at least two digits, more digits are used only if necessary. If the value is <code>​0​</code>, the exponent is also <code>​0​</code>. <i>Precision</i> specifies the exact number of digits to appear after the decimal point character. The default precision is <code>6</code>. In the <i>alternative implementation</i> decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>a</code><br><code>A</code> <p><span class="t-mark-rev t-since-c99">(C99)</span></p>
+</th> <td> Converts <b>floating-point number</b> to the hexadecimal exponent notation. <p>For the <code>a</code> conversion style <i>[-]</i><code>0x</code><i>h.hhh</i><code>p</code><i>±d</i> is used.<br> For the <code>A</code> conversion style <i>[-]</i><code>0X</code><i>h.hhh</i><code>P</code><i>±d</i> is used.<br> The first hexadecimal digit is not <code>0</code> if the argument is a normalized floating point value. If the value is <code>​0​</code>, the exponent is also <code>​0​</code>. <i>Precision</i> specifies the exact number of digits to appear after the hexadecimal point character. The default precision is sufficient for exact representation of the value. In the <i>alternative implementation</i> decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>g</code><br><code>G</code> </th> <td> Converts <b>floating-point number</b> to decimal or decimal exponent notation depending on the value and the <i>precision</i>. <p>For the <code>g</code> conversion style conversion with style <code>e</code> or <code>f</code> will be performed.<br> For the <code>G</code> conversion style conversion with style <code>E</code> or <code>F</code> will be performed.<br> Let <code>P</code> equal the precision if nonzero, <code>6</code> if the precision is not specified, or <code>1</code> if the precision is <code>​0​</code>. Then, if a conversion with style <code>E</code> would have an exponent of <code>X</code>:</p>
+<ul>
+<li> if <i>P &gt; X ≥ −4</i>, the conversion is with style <code>f</code> or <code>F</code> and precision <i>P − 1 − X</i>. </li>
+<li> otherwise, the conversion is with style <code>e</code> or <code>E</code> and precision <i>P − 1</i>. </li>
+</ul> <p>Unless <i>alternative representation</i> is requested the trailing zeros are removed, also the decimal point character is removed if no fractional part is left. For infinity and not-a-number conversion style see notes.</p>
+</td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>n</code> </th> <td> Returns the <b>number of characters written</b> so far by this call to the function. <p>The result is <i>written</i> to the value pointed to by the argument. The specification may not contain any <i>flag</i>, <i>field width</i>, or <i>precision</i>.<br><br><br><br></p>
+</td> <td>
+<div><code>signed char*</code></div> </td> <td>
+<div><code>short*</code></div> </td> <td>
+<div><code>int*</code></div> </td> <td>
+<div><code>long*</code></div> </td> <td>
+<div><code>long long*</code></div> </td> <td>
+<div><code><a href="http://en.cppreference.com/w/c/types/integer"><span class="kw118">intmax_t</span></a><span class="sy2">*</span></code></div> </td> <td>
+<div>signed <code><a href="http://en.cppreference.com/w/c/types/size_t"><span class="kw100">size_t</span></a><span class="sy2">*</span></code>
+</div> </td> <td>
+<div><code><a href="http://en.cppreference.com/w/c/types/ptrdiff_t"><span class="kw101">ptrdiff_t</span></a><span class="sy2">*</span></code></div> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr> <tr> <th>
+<code>p</code> </th> <td>Writes an implementation defined character sequence defining a <b>pointer</b>. </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td>
+<code>void*</code> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td> <td class="table-na"> <small>N/A</small> </td>
+</tr>
+</table> <p>The floating point conversion functions convert infinity to <code>inf</code> or <code>infinity</code>. Which one is used is implementation defined.</p>
+<p>Not-a-number is converted to <code>nan</code> or <code>nan(<i>char_sequence</i>)</code>. Which one is used is implementation defined.</p>
+<p>The conversions <code>F</code>, <code>E</code>, <code>G</code>, <code>A</code> output <code>INF</code>, <code>INFINITY</code>, <code>NAN</code> instead.</p>
+<p>Even though <code>%c</code> expects <code>int</code> argument, it is safe to pass a <code>char</code> because of the integer promotion that takes place when a variadic function is called.</p>
+<p>The correct conversion specifications for the fixed-width character types (<code><a href="../types/integer" title="c/types/integer">int8_t</a></code>, etc) are defined in the header <a href="../types/integer" title="c/types/integer"><code>&lt;inttypes.h&gt;</code></a> (although <code><a href="../types/integer" title="c/types/integer">PRIdMAX</a></code>, <code><a href="../types/integer" title="c/types/integer">PRIuMAX</a></code>, etc is synonymous with <code>%jd</code>, <code>%ju</code>, etc).</p>
+<p>The memory-writing conversion specifier <code>%n</code> is a common target of security exploits where format strings depend on user input and is not supported by the bounds-checked <code>printf_s</code> family of functions.</p>
+<p>There is a <a href="../language/eval_order" title="c/language/eval order">sequence point</a> after the action of each conversion specifier; this permits storing multiple <code>%n</code> results in the same variable or, as an edge case, printing a string modified by an earlier <code>%n</code> within the same call.</p>
+<p>If a conversion specification is invalid, the behavior is undefined.</p>
+<h3 id="Return_value"> Return value</h3> <div class="t-li1">
+<span class="t-li">1,4)</span> The number of wide characters written if successful or negative value if an error occurred.</div> <div class="t-li1">
+<span class="t-li">3)</span> The number of wide characters written if successful or negative value if an error occurred. If the resulting string gets truncated due to <code>bufsz</code> limit, function returns the total number of characters (not including the terminating null wide character) which would have been written, if the limit were not imposed. </div> <div class="t-li1">
+<span class="t-li">2,5)</span> number of wide characters transmitted to the output stream or negative value if an output error, a runtime constraints violation error, or an encoding error occurred.</div> <div class="t-li1">
+<span class="t-li">6)</span> number of wide characters written to <code>buffer</code>, not counting the null wide character (which is always written as long as <code>buffer</code> is not a null pointer and <code>bufsz</code> is not zero and not greater than <code>RSIZE_MAX/sizeof(wchar_t)</code>), or zero on runtime constraint violations, and negative value on encoding errors.</div> <div class="t-li1">
+<span class="t-li">7)</span> number of wide characters not including the terminating null character (which is always written as long as <code>buffer</code> is not a null pointer and <code>bufsz</code> is not zero and not greater than <code>RSIZE_MAX/sizeof(wchar_t)</code>), which would have been written to <code>buffer</code> if <code>bufsz</code> was ignored, or a negative value if a runtime constraints violation or an encoding error occurred.</div> <h3 id="Notes"> Notes</h3> <p>All these functions invoke <code>va_arg</code> at least once, the value of <code>arg</code> is indeterminate after the return. These functions to not invoke <code>va_end</code>, and it must be done by the caller.</p>
+<p>While narrow strings provide <code><a href="vfprintf" title="c/io/vfprintf">vsnprintf</a></code>, which makes it possible to determine the required output buffer size, there is no equivalent for wide strings (until C11's vsnwprintf_s), and in order to determine the buffer size, the program may need to call <code>vswprintf</code>, check the result value, and reallocate a larger buffer, trying again until successful.</p>
+<p><code>vsnwprintf_s</code>, unlike <code>vswprintf_s</code>, will truncate the result to fit within the array pointed to by <code>buffer</code>, even though truncation is treated as an error by most bounds-checked functions.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;time.h&gt;
+#include &lt;locale.h&gt;
+#include &lt;stdarg.h&gt;
+#include &lt;stddef.h&gt;
+#include &lt;wchar.h&gt;
+
+void debug_wlog(const wchar_t *fmt, ...)
+{
+ struct timespec ts;
+ timespec_get(&amp;ts, TIME_UTC);
+ char time_buf[100];
+ size_t rc = strftime(time_buf, sizeof time_buf, "%D %T", gmtime(&amp;ts.tv_sec));
+ snprintf(time_buf + rc, sizeof time_buf - rc, ".%06ld UTC", ts.tv_nsec / 1000);
+
+ va_list args;
+ va_start(args, fmt);
+ wchar_t buf[1024];
+ int rc2 = vswprintf(buf, sizeof buf / sizeof *buf, fmt, args);
+ va_end(args);
+
+ if(rc2 &gt; 0)
+ wprintf(L"%s [debug]: %ls\n", time_buf, buf);
+ else
+ wprintf(L"%s [debug]: (string too long)\n", time_buf);
+}
+
+int main(void)
+{
+ setlocale(LC_ALL, "");
+ debug_wlog(L"Logging, %d, %d, %d", 1, 2, 3);
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">02/20/15 22:12:38.476575 UTC [debug]: Logging, 1, 2, 3</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.29.2.5 The vfwprintf function (p: 417-418) </li>
+<li> 7.29.2.7 The vswprintf function (p: 419) </li>
+<li> 7.29.2.9 The vwprintf function (p: 420) </li>
+<li> K.3.9.1.6 The vfwprintf_s function (p: 632) </li>
+<li> K.3.9.1.8 The vsnwprintf_s function (p: 633-634) </li>
+<li> K.3.9.1.9 The vswprintf_s function (p: 634-635) </li>
+<li> K.3.9.1.11 The vwprintf_s function (p: 636) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.24.2.5 The vfwprintf function (p: 363) </li>
+<li> 7.24.2.7 The vswprintf function (p: 364) </li>
+<li> 7.24.2.9 The vwprintf function (p: 365) </li>
+</ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="vfprintf" title="c/io/vfprintf"> <span class="t-lines"><span>vprintf</span><span>vfprintf</span><span>vsprintf</span><span>vsnprintf</span><span>vprintf_s</span><span>vfprintf_s</span><span>vsprintf_s</span><span>vsnprintf_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> prints formatted output to <code><a href="std_streams" title="c/io/std streams">stdout</a></code>, a file stream or a buffer<br> using variable argument list <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="fwprintf" title="c/io/fwprintf"> <span class="t-lines"><span>wprintf</span><span>fwprintf</span><span>swprintf</span><span>wprintf_s</span><span>fwprintf_s</span><span>swprintf_s</span><span>snwprintf_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> prints formatted wide character output to <code><a href="std_streams" title="c/io/std streams">stdout</a></code>, a file stream or a buffer <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/io/c/vfwprintf" title="cpp/io/c/vfwprintf">C++ documentation</a></span> for <code>vwprintf, vfwprintf, vswprintf</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/io/vfwprintf" class="_attribution-link">https://en.cppreference.com/w/c/io/vfwprintf</a>
+ </p>
+</div>