Up and Running
19
Consider the following
printf
call, which prints the string
Ten 10, Twenty
20, Thirty 30
:
printf("Ten %d
u
, Twenty %d
v
, Thirty %d
w
", 10
x
, 20
y
, 30
z
);
The first argument,
"Ten %d, Twenty %d, Thirty %d"
, is the format string.
Notice that there are three format specifiers
%d
u
v
w
. There are also three
arguments after the format string
x
y
z
. When
printf
builds the output, it
replaces the argument at
u
with the one at
x
, the argument at
v
with the
one at
y
, and the argument at
w
with the one at
z
.
Dostları ilə paylaş: