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

📄 printf.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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-2004 IEEE and The Open Group, All Rights Reserved --><title>printf</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="printf"></a> <a name="tag_04_102"></a><!-- printf --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_102_01"></a>NAME</h4><blockquote>printf - write formatted output</blockquote><h4><a name="tag_04_102_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>printf</tt> <i>format</i><b>[</b><i>argument</i><tt>...</tt><b>]</b></code></p></blockquote><h4><a name="tag_04_102_03"></a>DESCRIPTION</h4><blockquote><p>The <i>printf</i> utility shall write formatted operands to the standard output. The <i>argument</i> operands shall be formattedunder control of the <i>format</i> operand.</p></blockquote><h4><a name="tag_04_102_04"></a>OPTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_102_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><dl compact><dt><i>format</i></dt><dd>A string describing the format to use to write the remaining operands. See the EXTENDED DESCRIPTION section.</dd><dt><i>argument</i></dt><dd>The strings to be written to standard output, under the control of <i>format</i>. See the EXTENDED DESCRIPTION section.</dd></dl></blockquote><h4><a name="tag_04_102_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_102_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_102_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>printf</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standarderror.</dd><dt><i>LC_NUMERIC</i></dt><dd>Determine the locale for numeric formatting. It shall affect the format of numbers written using the <tt>e</tt>, <tt>E</tt>,<tt>f</tt>, <tt>g</tt>, and <tt>G</tt> conversion specifier characters (if supported).</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_102_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_102_10"></a>STDOUT</h4><blockquote><p>See the EXTENDED DESCRIPTION section.</p></blockquote><h4><a name="tag_04_102_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_102_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_102_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>The <i>format</i> operand shall be used as the <i>format</i> string described in the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap05.html">Chapter 5, File Format Notation</a> with the followingexceptions:</p><ol><li><p>A &lt;space&gt; in the format string, in any context other than a flag of a conversion specification, shall be treated as anordinary character that is copied to the output.</p></li><li><p>A <tt>'<img src="../images/delta.gif" border="0">'</tt> character in the format string shall be treated as a <tt>'<img src="../images/delta.gif" border="0">'</tt> character, not as a &lt;space&gt;.</p></li><li><p>In addition to the escape sequences shown in the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap05.html">Chapter 5, File Format Notation</a> ( <tt>'\\'</tt>, <tt>'\a'</tt>, <tt>'\b'</tt>, <tt>'\f'</tt>,<tt>'\n'</tt>, <tt>'\r'</tt>, <tt>'\t'</tt>, <tt>'\v'</tt> ), <tt>"\ddd"</tt>, where <i>ddd</i> is a one, two, or three-digitoctal number, shall be written as a byte with the numeric value specified by the octal number.</p></li><li><p>The implementation shall not precede or follow output from the <tt>d</tt> or <tt>u</tt> conversion specifiers with&lt;blank&gt;s not specified by the <i>format</i> operand.</p></li><li><p>The implementation shall not precede output from the <tt>o</tt> conversion specifier with zeros not specified by the<i>format</i> operand.</p></li><li><p>The <tt>e</tt>, <tt>E</tt>, <tt>f</tt>, <tt>g</tt>, and <tt>G</tt> conversion specifiers need not be supported.</p></li><li><p>An additional conversion specifier character, <tt>b</tt>, shall be supported as follows. The argument shall be taken to be astring that may contain backslash-escape sequences. The following backslash-escape sequences shall be supported:</p><ul><li><p>The escape sequences listed in the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap05.html">Chapter 5, File Format Notation</a> ( <tt>'\\'</tt>, <tt>'\a'</tt>, <tt>'\b'</tt>, <tt>'\f'</tt>,<tt>'\n'</tt>, <tt>'\r'</tt>, <tt>'\t'</tt>, <tt>'\v'</tt> ), which shall be converted to the characters they represent</p></li><li><p><tt>"\0ddd"</tt>, where <i>ddd</i> is a zero, one, two, or three-digit octal number that shall be converted to a byte with thenumeric value specified by the octal number</p></li><li><p><tt>'\c'</tt>, which shall not be written and shall cause <i>printf</i> to ignore any remaining characters in the stringoperand containing it, any remaining string operands, and any additional characters in the <i>format</i> operand</p></li></ul><p>The interpretation of a backslash followed by any other sequence of characters is unspecified.</p><p>Bytes from the converted string shall be written until the end of the string or the number of bytes indicated by the precisionspecification is reached. If the precision is omitted, it shall be taken to be infinite, so all bytes up to the end of theconverted string shall be written.</p></li><li><p>For each conversion specification that consumes an argument, the next argument operand shall be evaluated and converted to theappropriate type for the conversion as specified below.</p></li><li><p>The <i>format</i> operand shall be reused as often as necessary to satisfy the argument operands. Any extra <tt>c</tt> or<tt>s</tt> conversion specifiers shall be evaluated as if a null string argument were supplied; other extra conversionspecifications shall be evaluated as if a zero argument were supplied. If the <i>format</i> operand contains no conversionspecifications and <i>argument</i> operands are present, the results are unspecified.</p></li><li><p>If a character sequence in the <i>format</i> operand begins with a <tt>'%'</tt> character, but does not form a valid conversionspecification, the behavior is unspecified.</p></li></ol><p>The <i>argument</i> operands shall be treated as strings if the corresponding conversion specifier is <tt>b</tt>, <tt>c</tt>,or <tt>s</tt> ; otherwise, it shall be evaluated as a C constant, as described by the ISO&nbsp;C standard, with the followingextensions:</p><ul><li><p>A leading plus or minus sign shall be allowed.</p></li><li><p>If the leading character is a single-quote or double-quote, the value shall be the numeric value in the underlying codeset ofthe character following the single-quote or double-quote.</p></li></ul><p>If an argument operand cannot be completely converted into an internal value appropriate to the corresponding conversionspecification, a diagnostic message shall be written to standard error and the utility shall not exit with a zero exit status, butshall continue processing any remaining operands and shall write the value accumulated at the time the error was detected tostandard output.</p><p>It is not considered an error if an argument operand is not completely used for a <tt>c</tt> or <tt>s</tt> conversion or if astring operand's first or second character is used to get the numeric value of a character.</p></blockquote><h4><a name="tag_04_102_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt>&nbsp;0</dt><dd>Successful completion.</dd><dt>&gt;0</dt><dd>An error occurred.</dd></dl></blockquote>

⌨️ 快捷键说明

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