section 7.2: Formatted Output -- Printf
pages 153-155
To summarize the important points of this section:
- printf's output goes to the standard output,
just like putchar.
- Everything in printf's format string
is either
a plain character to be printed as-is,
or a %-specifier which
generally
causes one
argument to be consumed, formatted, and printed.
(Occasionally,
a single %-specifier consumes
two or three arguments if the width or precision is *,
or zero arguments if the specifier is %%.)
- There's a fairly long list of conversion specifiers;
see the table on page 154.
- Always be careful that the conversions you request
(in the format string)
match the arguments you supply.
- You can ``print'' to a string
(instead of the standard output)
with sprintf.
(This is the usual way of converting numbers to strings in C;
the itoa function we were playing with
in section 3.6 on page 64
is nonstandard, and unnecessary.)
Read sequentially:
prev
next
up
top
This page by Steve Summit
// Copyright 1995, 1996
// mail feedback