171 lines
4.1 KiB
HTML
171 lines
4.1 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||
|
<meta http-equiv="Content-Type" content=
|
||
|
"text/html; charset=utf-8">
|
||
|
<title>printf - Write formatted output</title>
|
||
|
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</HEAD>
|
||
|
<body bgcolor="#FFFFFF">
|
||
|
<!-- Java sync-link -->
|
||
|
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
||
|
|
||
|
|
||
|
|
||
|
<h2>printf - Write formatted output</h2>
|
||
|
|
||
|
<strong>Synopsis</strong>
|
||
|
|
||
|
<p><strong>printf</strong> <em>format</em> [ <em>argument</em> ...
|
||
|
]</p>
|
||
|
|
||
|
<p><strong>Description</strong></p>
|
||
|
|
||
|
<p>You can use <strong>printf</strong> to format and display output
|
||
|
on standard output. The syntax is similar to the ILE C printf()
|
||
|
function. <strong>printf</strong> formats using the following
|
||
|
conversion control string syntax:</p>
|
||
|
|
||
|
<p>
|
||
|
%[<em>flags</em>][<em>width</em>].[<em>precision</em>]<em>conversion</em></p>
|
||
|
|
||
|
<p><em>conversion</em> specifies how the corresponding <em>
|
||
|
argument</em> is displayed. You must specify one of the following
|
||
|
conversion characters:</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>c</strong></dt>
|
||
|
|
||
|
<dd>Unsigned character.</dd>
|
||
|
|
||
|
<dt><strong>d</strong></dt>
|
||
|
|
||
|
<dd>Signed decimal number.</dd>
|
||
|
|
||
|
<dt><strong>e,E</strong></dt>
|
||
|
|
||
|
<dd>Scientific notation.</dd>
|
||
|
|
||
|
<dt><strong>f</strong></dt>
|
||
|
|
||
|
<dd>Floating point number.</dd>
|
||
|
|
||
|
<dt><strong>g,G</strong></dt>
|
||
|
|
||
|
<dd>Scientific notation with significant digits.</dd>
|
||
|
|
||
|
<dt><strong>i</strong></dt>
|
||
|
|
||
|
<dd>Signed decimal number.</dd>
|
||
|
|
||
|
<dt><strong>o</strong></dt>
|
||
|
|
||
|
<dd>Unsigned octal number.</dd>
|
||
|
|
||
|
<dt><strong>s</strong></dt>
|
||
|
|
||
|
<dd>String.</dd>
|
||
|
|
||
|
<dt><strong>u</strong></dt>
|
||
|
|
||
|
<dd>Unsigned decimal number.</dd>
|
||
|
|
||
|
<dt><strong>x</strong></dt>
|
||
|
|
||
|
<dd>Unsigned hexadecimal number with digits 0123456789abcdef.</dd>
|
||
|
|
||
|
<dt><strong>X</strong></dt>
|
||
|
|
||
|
<dd>Unsigned hexadecimal number with digits 0123456789ABCDEF.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<p><em>flags</em> control how the <em>argument</em> is displayed in
|
||
|
the following ways:</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>-</strong> (minus)</dt>
|
||
|
|
||
|
<dd>Left align <em>argument</em> within the field.</dd>
|
||
|
|
||
|
<dt><strong>+</strong> (plus)</dt>
|
||
|
|
||
|
<dd>Prefix all numbers with a + or -.</dd>
|
||
|
|
||
|
<dt><strong>space</strong></dt>
|
||
|
|
||
|
<dd>Prefix positive numbers with <space> and negative numbers
|
||
|
with -.</dd>
|
||
|
|
||
|
<dt><strong>0</strong></dt>
|
||
|
|
||
|
<dd>Pad field width with leading zeros for <strong>d, e, E, f,
|
||
|
g</strong>, or <strong>G</strong>.</dd>
|
||
|
|
||
|
<dt><strong>#</strong></dt>
|
||
|
|
||
|
<dd>Use an alternate output form depending on conversion character.
|
||
|
For <strong>o</strong>, prefix octal numbers with "0". For <strong>
|
||
|
x</strong>, prefix hexadecimal numbers with "0x". For <strong>
|
||
|
X</strong>, prefix hexadecimal numbers with "0X". For <strong>e, E,
|
||
|
f, g</strong>, or <strong>G</strong>, display decimal point. For
|
||
|
<strong>g</strong> or <strong>G</strong>, display trailing
|
||
|
zeros.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<p><em>width</em> is the minimum number of character positions
|
||
|
displayed. Using an asterisk (*) character for the width means the
|
||
|
value of the next <em>argument</em> is the field width.</p>
|
||
|
|
||
|
<p>The meaning of <em>precision</em> depends on the conversion
|
||
|
character.</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>For <strong>d, i, o, u, x</strong>, or <strong>X</strong> <em>
|
||
|
precision</em> specifies the minimum number of digits to be
|
||
|
displayed.</li>
|
||
|
|
||
|
<li>For <strong>e, E</strong>, or <strong>f</strong> <em>
|
||
|
precision</em> specifies the number of digits to be displayed after
|
||
|
the decimal point.</li>
|
||
|
|
||
|
<li>For <strong>g</strong>, or <strong>G</strong> <em>
|
||
|
precision</em> specifies the maximum number of significant
|
||
|
digits.</li>
|
||
|
|
||
|
<li>For <strong>s</strong> <em>precision</em> specifies the maximum
|
||
|
number of characters to be displayed.</li>
|
||
|
</ul>
|
||
|
|
||
|
<p><strong>Options</strong></p>
|
||
|
|
||
|
<p>None.</p>
|
||
|
|
||
|
<p><strong>Operands</strong></p>
|
||
|
|
||
|
<p>Each <em>argument</em> is converted and displayed as specified
|
||
|
by the <em>format</em>.</p>
|
||
|
|
||
|
<p><strong>Exit Status</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li>0 when successful.</li>
|
||
|
|
||
|
<li>>0 when unsuccessful.</li>
|
||
|
</ul>
|
||
|
|
||
|
<p><strong>Related information</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="dspmsg.htm">dspmsg - Display message from message
|
||
|
catalog</a></li>
|
||
|
|
||
|
<li><a href="echo.htm">echo - Write arguments to standard
|
||
|
output</a></li>
|
||
|
|
||
|
<li><a href="print.htm">print - Write output</a></li>
|
||
|
</ul>
|
||
|
</body>
|
||
|
</html>
|
||
|
|