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

📄 snprintf.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<dt>o<dd>The <b>unsigned int</b> argument is converted to unsigned octal formatin the style <i>dddd</i>.The precision specifies the minimum number of digits to appear; ifthe value being converted can be represented in fewer digits, it will beexpanded with leading zeros. The default precision is 1. The result ofconverting 0 with an explicit precision of 0 is no characters.<dt>u<dd>The <b>unsigned int</b> argument is converted to unsigned decimal formatin the style<i>dddd</i>.The precision specifies the minimum number of digits to appear; ifthe value being converted can be represented in fewer digits, it will beexpanded with leading zeros. The default precision is 1. The result ofconverting 0 with an explicit precision of 0 is no characters.<dt>x<dd>The <b>unsigned int</b> argument is converted to unsigned hexadecimal formatin the style<i>dddd</i>;the letters abcdef are used.The precision specifies the minimum number of digits to appear; ifthe value being converted can be represented in fewer digits, it will beexpanded with leading zeros. The default precision is 1. The result ofconverting 0 with an explicit precision of 0 is no characters.<dt>X<dd>Behaves the same as the x conversion character except thatletters ABCDEF are used instead of abcdef.<dt>f<dd>The<b>double</b>argument is converted to decimal notation in the style<b>[</b>-<b>]</b><i>ddd.ddd</i>, where the number of digits after theradix character is equal to the precision specification.If the precision is missing, it is taken as 6; if the precision isexplicitly 0 and no # flag is present, no radix character appears.If a radix character appears, at least one digit appearsbefore it.The value is rounded to the appropriate number of digits.The<i>fprintf()</i>family of functions may make available character string representationsfor infinity and NaN.<dt>e, E<dd>The<b>double</b>argument is converted in the style<b>[</b>-<b>]</b><i>d.ddd</i>e<i>&plusmn;dd</i>,where there is one digit before the radix character(which is non-zero if the argument is non-zero) and the number ofdigits after it is equal to the precision; if the precision ismissing, it is taken as 6; if the precision is 0 and no # flagis present, no radix character appears.The value is rounded to the appropriate number of digits.The E conversion character will produce a number with E instead of eintroducing the exponent.The exponent always contains at least two digits.If the value is 0, the exponent is 0.The<i>fprintf()</i>family of functions may make available character string representationsfor infinity and NaN.<dt>g, G<dd>The<b>double</b>argument is converted in the style f or e (or in the style Ein the case of a G conversion character),with the precision specifying the number of significant digits.If an explicit precision is 0, it is taken as 1.The style used depends on the value converted; style e (or E)will be used only if the exponent resulting from such aconversion is less than -4 or greater than or equal to theprecision.Trailing zeros are removed from the fractional portion of theresult; a radix character appears only if it is followedby a digit.The<i>fprintf()</i>family of functions may make available character string representationsfor infinity and NaN.<dt>c<dd>The<b>int</b>argument is converted to an<b>unsigned char</b>,and the resulting byte is written.If an l (ell) qualifier is present, the<b>wint_t</b>argument is converted as if by an ls conversion specification with noprecision and an argument that points to a two-element array of type<b>wchar_t</b>,the first element of which contains the <b>wint_t</b>argument to the ls conversion specification and the secondelement contains a null wide-character.<dt>s<dd>The argument must be a pointer to an array of<b>char</b>,Bytes from the array are written up to (but not including) anyterminating null byte.If the precision is specified, nomore than that many bytes are written.If the precision is not specified or is greater than the size ofthe array, the array must contain a null byte.If an l (ell) qualifier is present, the argument must be a pointer to an array of type<b>wchar_t</b>.Wide-characters from the array are converted to characters(each as if by a call to the<i><a href="wcrtomb.html">wcrtomb()</a></i>function, with the conversion state described by an<b>mbstate_t</b>object initialised to zero before the first wide-character isconverted) up to and including a terminating null wide-character.  Theresulting characters are written up to (but not including)the terminating null character (byte).  If no precision is specified,the array must contain a null wide-character.   If a precision isspecified, no more than that many characters (bytes) are written(including shift sequences, if any), and the array must contain a nullwide-character if, to equal the character sequence lengthgiven by the precision, the function would need to access a wide-character one past the end of the array.  In no case is a partialcharacter written.<dt>p<dd>The argument must be a pointer to<b>void</b>.The value of the pointer is converted to a sequence of printablecharacters, in an implementation-dependent manner.<dt>n<dd>The argument must be a pointer to an integer into which is writtenthe number of bytes written to the output so far by this call to one of the<i>fprintf()</i>functions.No argument is converted.<dt>C<dd>Same as lc.<dt>S<dd>Same as ls.<dt>%<dd>Print a %; no argument is converted.The entire conversion specification must be %%.</dl><p>If a conversion specification does not match one of theabove forms, the behaviour is undefined.<p>In no case does a non-existent or small field widthcause truncation of a field;if the result of a conversion is wider than the field width,the field is simply expanded to contain the conversion result.Characters generated by<i>fprintf()</i>and<i><a href="printf.html">printf()</a></i>are printed as if<i><a href="fputc.html">fputc()</a></i>had been called.<p>The<i>st_ctime</i>and<i>st_mtime</i>fields of the file will be marked for update between the call toa successful execution of<i>fprintf()</i>or<i><a href="printf.html">printf()</a></i>and the next successful completion of a call to<i><a href="fflush.html">fflush()</a></i>or<i><a href="fclose.html">fclose()</a></i>on the same stream or a call to<i><a href="exit.html">exit()</a></i>or<i><a href="abort.html">abort()</a></i>.</blockquote><h4><a name = "tag_000_008_807">&nbsp;</a>RETURN VALUE</h4><blockquote>Upon successful completion, these functionsreturn the number of bytes transmittedexcluding the terminating null in the case of<i>sprintf()</i>or<i>snprintf()</i>or a negative value if an output error was encountered.<p>If the value of<i>n</i>is zero on a call to<i>snprintf()</i>,an unspecified value less than 1 is returned.</blockquote><h4><a name = "tag_000_008_808">&nbsp;</a>ERRORS</h4><blockquote>For the conditions under which<i>fprintf()</i>and<i><a href="printf.html">printf()</a></i>will fail and may fail, refer to<i><a href="fputc.html">fputc()</a></i>or<i><a href="fputwc.html">fputwc()</a></i>.<p>In addition, all forms of<i>fprintf()</i>may fail if:<dl compact><dt>[EILSEQ]<dd>A wide-character code that does not correspond to a valid character has beendetected.<dt>[EINVAL]<dd>There are insufficient arguments.</dl><p>In addition,<i><a href="printf.html">printf()</a></i>and<i>fprintf()</i>may fail if:<dl compact><dt>[ENOMEM]<dd>Insufficient storage space is available.</dl></blockquote><h4><a name = "tag_000_008_809">&nbsp;</a>EXAMPLES</h4><blockquote>To print the language-independent date and time format, thefollowing statement could be used:<pre><code>printf (format, weekday, month, day, hour, min);</code></pre>For American usage,<i>format</i>could be a pointer to the string:<pre><code>"%s, %s %d, %d:%.2d\n"</code></pre>producing the message:<pre><code>Sunday, July 3, 10:02</code></pre>whereas for German usage,<i>format</i>could be a pointer to the string:<pre><code>"%1$s, %3$d. %2$s, %4$d:%5$.2d\n"</code></pre>producing the message:<pre><code>Sonntag, 3. Juli, 10:02</code></pre></blockquote><h4><a name = "tag_000_008_810">&nbsp;</a>APPLICATION USAGE</h4><blockquote>If the application calling<i>fprintf()</i>has any objects of type<b>wint_t</b>or<b>wchar_t,</b>it must also include the header<i><a href="wchar.h.html">&lt;wchar.h&gt;</a></i>to have these objects defined.</blockquote><h4><a name = "tag_000_008_811">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_008_812">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="fputc.html">fputc()</a></i>,<i><a href="fscanf.html">fscanf()</a></i>,<i><a href="setlocale.html">setlocale()</a></i>,<i><a href="wcrtomb.html">wcrtomb()</a></i>,<i><a href="stdio.h.html">&lt;stdio.h&gt;</a></i>,<i><a href="wchar.h.html">&lt;wchar.h&gt;</a></i>,the <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b>&nbsp;</a>,<i><a href="http://www.opengroup.org/platform/resolutions/bwg98-006.html">Base Working Group Resolution # bwg98-006</a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

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