📄 fwprintf.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>fwprintf</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="fwprintf"></a> <a name="tag_03_204"></a><!-- fwprintf --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_204_01"></a>NAME</h4><blockquote>fwprintf, swprintf, wprintf - print formatted wide-character output</blockquote><h4><a name="tag_03_204_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include <<a href="../basedefs/stdio.h.html">stdio.h</a>><br> #include <<a href="../basedefs/wchar.h.html">wchar.h</a>><br><br> int fwprintf(FILE *restrict</tt> <i>stream</i><tt>, const wchar_t *restrict</tt> <i>format</i><tt>, ...);<br> int swprintf(wchar_t *restrict</tt> <i>ws</i><tt>, size_t</tt> <i>n</i><tt>,<br> const wchar_t *restrict</tt> <i>format</i><tt>, ...);<br> int wprintf(const wchar_t *restrict</tt> <i>format</i><tt>, ...);<br></tt></code></p></blockquote><h4><a name="tag_03_204_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO C standard. Any conflict between therequirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers tothe ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>fwprintf</i>() function shall place output on the named output <i>stream</i>. The <i>wprintf</i>() function shall placeoutput on the standard output stream <i>stdout</i>. The <i>swprintf</i>() function shall place output followed by the null widecharacter in consecutive wide characters starting at *<i>ws</i>; no more than <i>n</i> wide characters shall be written, includinga terminating null wide character, which is always added (unless <i>n</i> is zero).</p><p>Each of these functions shall convert, format, and print its arguments under control of the <i>format</i> wide-character string.The <i>format</i> is composed of zero or more directives: <i>ordinary wide-characters</i>, which are simply copied to the outputstream, and <i>conversion specifications</i>, each of which results in the fetching of zero or more arguments. The results areundefined if there are insufficient arguments for the <i>format</i>. If the <i>format</i> is exhausted while arguments remain, theexcess arguments are evaluated but are otherwise ignored.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Conversions can be applied to the <i>n</i>th argument after the <i>format</i> in the argument list, rather than to the next unusedargument. In this case, the conversion specifier wide character <tt>%</tt> (see below) is replaced by the sequence <tt>"%n$"</tt> ,where <i>n</i> is a decimal integer in the range [1,{NL_ARGMAX}], giving the position of the argument in the argument list. Thisfeature provides for the definition of <i>format</i> wide-character strings that select arguments in an order appropriate tospecific languages (see the EXAMPLES section).</p><p>The <i>format</i> can contain either numbered argument specifications (that is, <tt>"%</tt><i>n</i><tt>$"</tt> and<tt>"*</tt><i>m</i><tt>$"</tt>), or unnumbered argument conversion specifications (that is, <tt>%</tt> and <tt>*</tt> ), but notboth. The only exception to this is that <tt>%%</tt> can be mixed with the <tt>"%</tt><i>n</i><tt>$"</tt> form. The results ofmixing numbered and unnumbered argument specifications in a <i>format</i> wide-character string are undefined. When numberedargument specifications are used, specifying the <i>N</i>th argument requires that all the leading arguments, from the first to the(<i>N</i>-1)th, are specified in the <i>format</i> wide-character string.</p><p>In <i>format</i> wide-character strings containing the <tt>"%</tt><i>n</i><tt>$"</tt> form of conversion specification, numberedarguments in the argument list can be referenced from the <i>format</i> wide-character string as many times as required. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>In <i>format</i> wide-character strings containing the <tt>%</tt> form of conversion specification, each argument in theargument list shall be used exactly once.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Allforms of the <i>fwprintf</i>() function allow for the insertion of a locale-dependent radix character in the output string, outputas a wide-character value. The radix character is defined in the program's locale (category <i>LC_NUMERIC ).</i> In the POSIXlocale, or in a locale where the radix character is not defined, the radix character shall default to a period ( <tt>'.'</tt> ).<img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>Each conversion specification is introduced by the <tt>'%'</tt> wide character <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or by thewide-character sequence <tt>"%</tt><i>n</i><tt>$"</tt>, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> afterwhich the following appear in sequence:</p><ul><li><p>Zero or more <i>flags</i> (in any order), which modify the meaning of the conversion specification.</p></li><li><p>An optional minimum <i>field width</i>. If the converted value has fewer wide characters than the field width, it shall bepadded with spaces by default on the left; it shall be padded on the right, if the left-adjustment flag ( <tt>'-'</tt> ), describedbelow, is given to the field width. The field width takes the form of an asterisk ( <tt>'*'</tt> ), described below, or a decimalinteger.</p></li><li><p>An optional <i>precision</i> that gives the minimum number of digits to appear for the <tt>d</tt> , <tt>i</tt> , <tt>o</tt> ,<tt>u</tt> , <tt>x</tt> , and <tt>X</tt> conversion specifiers; the number of digits to appear after the radix character for the<tt>a</tt> , <tt>A</tt> , <tt>e</tt> , <tt>E</tt> , <tt>f</tt> , and <tt>F</tt> conversion specifiers; the maximum number ofsignificant digits for the <tt>g</tt> and <tt>G</tt> conversion specifiers; or the maximum number of wide characters to be printedfrom a string in the <tt>s</tt> conversion specifiers. The precision takes the form of a period ( <tt>'.'</tt> ) followed either byan asterisk ( <tt>'*'</tt> ), described below, or an optional decimal digit string, where a null digit string is treated as 0. If aprecision appears with any other conversion wide character, the behavior is undefined.</p></li><li><p>An optional length modifier that specifies the size of the argument.</p></li><li><p>A <i>conversion specifier</i> wide character that indicates the type of conversion to be applied.</p></li></ul><p>A field width, or precision, or both, may be indicated by an asterisk ( <tt>'*'</tt> ). In this case an argument of type<b>int</b> supplies the field width or precision. Applications shall ensure that arguments specifying field width, or precision, orboth appear in that order before the argument, if any, to be converted. A negative field width is taken as a <tt>'-'</tt> flagfollowed by a positive field width. A negative precision is taken as if the precision were omitted. <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> In<i>format</i> wide-character strings containing the <tt>"%</tt><i>n</i><tt>$"</tt> form of a conversion specification, a fieldwidth or precision may be indicated by the sequence <tt>"*</tt><i>m</i><tt>$"</tt>, where <i>m</i> is a decimal integer in therange [1,{NL_ARGMAX}] giving the position in the argument list (after the <i>format</i> argument) of an integer argument containingthe field width or precision, for example:</p><pre><tt>wprintf(L"%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></pre><p>The flag wide characters and their meanings are:</p><dl compact><dt><tt>'</tt></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The integer portion of the result of a decimal conversion ( <tt>%i</tt> , <tt>%d</tt> , <tt>%u</tt> , <tt>%f</tt> , <tt>%F</tt> ,<tt>%g</tt> , or <tt>%G</tt> ) shall be formatted with thousands' grouping wide characters. For other conversions, the behavior isundefined. The numeric grouping wide character is used. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><tt>-</tt></dt><dd>The result of the conversion shall be left-justified within the field. The conversion shall be right-justified if this flag isnot specified.</dd><dt><tt>+</tt></dt><dd>The result of a signed conversion shall always begin with a sign ( <tt>'+'</tt> or <tt>'-'</tt> ). The conversion shall beginwith a sign only when a negative value is converted if this flag is not specified.</dd><dt><space></dt><dd>If the first wide character of a signed conversion is not a sign, or if a signed conversion results in no wide characters, a<space> shall be prefixed to the result. This means that if the <space> and <tt>'+'</tt> flags both appear, the<space> flag shall be ignored.</dd><dt><tt>#</tt></dt><dd>Specifies that the value is to be converted to an alternative form. For <tt>o</tt> conversion, it increases the precision (ifnecessary) to force the first digit of the result to be 0. For <tt>x</tt> or <tt>X</tt> conversion specifiers, a non-zero resultshall have 0x (or 0X) prefixed to it. For <tt>a</tt> , <tt>A</tt> , <tt>e</tt> , <tt>E</tt> , <tt>f</tt> , <tt>F</tt> , <tt>g</tt>, and <tt>G</tt> conversion specifiers, the result shall always contain a radix character, even if no digits follow it. Withoutthis flag, a radix character appears in the result of these conversions only if a digit follows it. For <tt>g</tt> and <tt>G</tt>conversion specifiers, trailing zeros shall <i>not</i> be removed from the result as they normally are. For other conversionspecifiers, the behavior is undefined.</dd><dt><tt>0</tt></dt><dd>For <tt>d</tt> , <tt>i</tt> , <tt>o</tt> , <tt>u</tt> , <tt>x</tt> , <tt>X</tt> , <tt>a</tt> , <tt>A</tt> , <tt>e</tt> ,<tt>E</tt> , <tt>f</tt> , <tt>F</tt> , <tt>g</tt> , and <tt>G</tt> conversion specifiers, leading zeros (following any indicationof sign or base) are used to pad to the field width; no space padding is performed. If the <tt>'0'</tt> and <tt>'-'</tt> flags bothappear, the <tt>'0'</tt> flag shall be ignored. For <tt>d</tt> , <tt>i</tt> , <tt>o</tt> , <tt>u</tt> , <tt>x</tt> , and <tt>X</tt>conversion specifiers, if a precision is specified, the <tt>'0'</tt> flag shall be ignored. If the <tt>'0'</tt> and <tt>'"</tt>flags both appear, the grouping wide characters are inserted before zero padding. For other conversions, the behavior isundefined.</dd></dl><p>The length modifiers and their meanings are:</p><dl compact><dt><tt>hh</tt></dt><dd>Specifies that a following <tt>d</tt> , <tt>i</tt> , <tt>o</tt> , <tt>u</tt> , <tt>x</tt> , or <tt>X</tt> conversion specifierapplies to a <b>signed char</b> or <b>unsigned char</b> argument (the argument will have been promoted according to the integerpromotions, but its value shall be converted to <b>signed char</b> or <b>unsigned char</b> before printing); or that a following<tt>n</tt> conversion specifier applies to a pointer to a <b>signed char</b> argument.</dd><dt><tt>h</tt></dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -