⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fwprintf.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>fwprintf</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_404">&nbsp;</a>NAME</h4><blockquote>fwprintf, wprintf, swprintf - print formatted wide-character output</blockquote><h4><a name = "tag_000_005_405">&nbsp;</a>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="stdio.h.html">stdio.h</a>&gt;#include &lt;<a href="wchar.h.html">wchar.h</a>&gt;int fwprintf(FILE *<i>stream</i>, const wchar_t *<i>format</i>, ...);int wprintf(const wchar_t *<i>format</i>, ...);int swprintf(wchar_t *s, size_t <i>n</i>, const wchar_t *<i>format</i>, ...);</code></pre></blockquote><h4><a name = "tag_000_005_406">&nbsp;</a>DESCRIPTION</h4><blockquote>The<i>fwprintf()</i>function places output on the named output<i>stream</i>.The<i><a href="wprintf.html">wprintf()</a></i>function places output on the standard output stream<i>stdout</i>.The<i><a href="swprintf.html">swprintf()</a></i>function places output followed by the null wide-characterin consecutive wide-characters starting at<i> *s</i>;no more than <i>n</i>wide-characters are written, including a terminating null wide-character, which is always added (unless <i>n</i>is zero).<p>Each of these functionsconverts, formats and prints its argumentsunder 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 output stream and<i>conversion specifications</i>,each of which results in the fetching of zero or more arguments.  The resultsare undefined if there are insufficient arguments for the<i>format</i>.If the<i>format</i>is exhausted whilearguments remain, the excessarguments are evaluated but are otherwise ignored.<p>Conversions can be applied to the<i>n</i>thargument after the<i>format</i>in the argument list, rather than to the next unused argument.In this case, the conversion wide-character % (see below) is replacedby the sequence<i>%n$</i>,where n is a decimal integer in the range [1,&nbsp;{NL_ARGMAX}],giving the position of the argument in the argument list.This feature provides for the definition of format wide-characterstrings thatselect arguments in an order appropriate to specific languages(see the EXAMPLES section).<p>In format wide-character stringscontaining the<i>%n$</i>form of conversion specifications, numberedarguments in the argument list can be referenced from the format wide-character stringas many times as required.<p>In format wide-character strings containing the % form of conversion specifications,each argument in the argument list is used exactly once.<p>All forms of the<i>fwprintf()</i>functions allow for the insertion ofa language-dependent radix character in the output string, output asa wide-character value.The radix character is definedin the program's locale (category LC_NUMERIC).In the POSIX locale, or in a locale wherethe radix character is not defined,the radix character defaults to a period (.).<p>Each conversion specification is introduced by the % wide-characteror by the wide-character sequence<i>%n$</i>,after which the following appear in sequence:<ul><p><li>Zero or more<i>flags</i>(in any order), which modify the meaning of the conversion specification.<p><li>An optional minimum<i>field width</i>.If the converted value has fewer wide-characters than the fieldwidth, it will be padded with spaces by defaulton the left; it will be padded on the right, if theleft-adjustment flag (-),described below, is given to the field width.The field width takes the form of an asterisk (*), describedbelow, or a decimal integer.<p><li>An optional<i>precision</i>that gives the minimum number of digits to appear for the d, i, o, u, xand X conversions; the number of digits to appear afterthe radix character for the e, E and fconversions; the maximum number of significant digits for the g and Gconversions; or the maximum number of wide-charactersto be printed from a string in s conversions.The precision takes the form of a period (.) followed eitherby an asterisk (*), described below, or an optional decimal digit string,where a null digit string is treated as 0.  If a precision appears with anyother conversion wide-character, the behaviour is undefined.<p><li>An optional l (ell) specifying that a following c conversion wide-characterapplies to a<b>wint_t</b>argument; an optional l specifying that a following sconversion wide-character applies to a <b>wchar_t</b>argument; an optional h specifying that a following d, i, o, u, x or Xconversion wide-character applies to a type<b>short int</b>or type<b>unsigned short int</b>argument (the argument will have been promoted according to theintegral promotions, and its value will be converted to type<b>short int</b>or<b>unsigned short int</b>before printing); an optional hspecifying that a following nconversion wide-character applies to a pointer to a type<b>short int</b>argument; an optional l (ell) specifying that a following d, i, o, u, x or Xconversion wide-character applies to a type<b>long int</b>or<b>unsigned long int</b>argument; an optional l (ell) specifying that a following nconversion wide-character applies to a pointer to a type<b>long int</b>argument; or an optional L specifying that a following e, E, f, g or Gconversion wide-character applies to a type<b>long double</b>argument.If an h, l or L appears with any other conversion wide-character, the behaviour is undefined.<br><p><li>A<i>conversion wide-character</i>that indicates the type of conversion to be applied.<p></ul><p>A field width, or precision, or both, may be indicated by anasterisk (*).In this case an argument of type<b>int</b>supplies the field width or precision.Arguments specifying fieldwidth, or precision, or both must appear in that orderbefore the argument, if any, to be converted.A negative field width is taken as a - flag followed by apositive field width.A negative precision is taken as if the precision were omitted.&nbsp;In format wide-character strings containing the<i>%n$</i>form of a conversion specification, a field width or precision may beindicated by the sequence<i>*m$</i>,where<i>m</i>is a decimal integer in the range [1,&nbsp;{NL_ARGMAX}] givingthe position in the argument list (after the format argument) of an integerargument containing the field width or precision, for example:<pre><code>wprintf(L"%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec); </code></pre><p>The<i>format</i>can contain either numbered argument specifications(that is,<i>%n$</i>and<i>*m$</i>),or unnumbered argument specifications (that is, % and *),but normally not both.The only exception to this is that %%can be mixed with the<i>%n$</i>form.The results of mixing numbered and unnumbered argumentspecifications in a<i>format</i>wide-character string are undefined.When numbered argument specifications are used, specifying the<i>N</i>thargument requires that all the leading arguments,from the first to the (<i>N-1</i>)th, arespecified in the format wide-character string.<p>The flag wide-characters and their meanings are:<dl compact><dt>'<dd>The integer portion of the result of a decimal conversion(%i, %d, %u, %f, %g or %G)will be formatted with thousands' grouping wide-characters.For other conversions the behaviour is undefined.The non-monetary grouping wide-character is used.<dt>-<dd>The result of the conversion will be left-justified within the field.The conversion will be right-justified if this flag is notspecified.<dt>+<dd>The result of a signedconversion will always begin with a sign (+ or -).The conversion will begin with a sign only when a negative valueis converted if this flag is not specified.<dt>space<dd>If the first wide-character of a signed conversion is not a sign or ifa signed conversion results in no wide-characters, a spacewill be prefixed to the result.This means that if the space and +flags both appear, the space flag will be ignored.<dt>#<dd>This flag specifies that the value is to be convertedto an alternative form.For o conversion, it increases the precision (if necessary) to forcethe first digit of the result to be 0.For x or X conversions, a non-zero result will have 0x (or 0X)prefixed to it.For e, E, f, g or Gconversions, the result will always contain a radix character,even if no digits follow it.Without this flag, a radix character appearsin the result of these conversions only if a digitfollows it.For g and G conversions, trailing zeros will<i>not</i>be removed from the resultas they normally are.For other conversions, the behaviour is undefined.<dt>0<dd>For d, i, o, u, x, X, e, E, f, g and Gconversions, leading zeros (following any indication of sign orbase) are used to pad to the field width; no space padding isperformed.If the 0 and - flags both appear, the 0 flag will be ignored.For d, i, o, u, x and Xconversions, if a precision is specified, the 0flag will be ignored.If the 0 and ' flags both appear, the groupingwide-characters are inserted before zero padding.For other conversions, the behaviour is undefined.</dl>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -