* better
[mascara-docs.git] / lang / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx10b.html
blobdd075b2cab88bd7583cc514693c88a1afa7e3db5
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>section 7.2: Formatted Output -- Printf</title>
10 <link href="sx10a.html" rev=precedes>
11 <link href="sx10c.html" rel=precedes>
12 <link href="sx10.html" rev=subdocument>
13 </head>
14 <body>
15 <H2>section 7.2: Formatted Output -- Printf</H2>
17 pages 153-155
18 <p>To summarize the important points of this section:
19 <UL><li><TT>printf</TT>'s output goes to the standard output,
20 just like <TT>putchar</TT>.
21 <li>Everything in <TT>printf</TT>'s format string
22 is either
23 a plain character to be printed as-is,
24 or a <TT>%</TT>-specifier which
25 generally
26 causes one
27 argument to be consumed, formatted, and printed.
28 (Occasionally,
29 a single <TT>%</TT>-specifier consumes
30 two or three arguments if the width or precision is <TT>*</TT>,
31 or zero arguments if the specifier is <TT>%%</TT>.)
32 <li>There's a fairly long list of conversion specifiers;
33 see the table on page 154.
34 <li>Always be careful that the conversions you request
35 (in the format string)
36 match the arguments you supply.
37 <li>You can ``print'' to a string
38 (instead of the standard output)
39 with <TT>sprintf</TT>.
40 (This is the usual way of converting numbers to strings in C;
41 the <TT>itoa</TT> function we were playing with
42 in section 3.6 on page 64
43 is nonstandard, and unnecessary.)
44 </UL></p><hr>
45 <p>
46 Read sequentially:
47 <a href="sx10a.html" rev=precedes>prev</a>
48 <a href="sx10c.html" rel=precedes>next</a>
49 <a href="sx10.html" rev=subdocument>up</a>
50 <a href="top.html">top</a>
51 </p>
52 <p>
53 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
54 // <a href="copyright.html">Copyright</a> 1995, 1996
55 // <a href="mailto:scs@eskimo.com">mail feedback</a>
56 </p>
57 </body>
58 </html>