int printf ( const char * format , ... ) ; | <stdio.h> |
Print formatted data to stdout.
The C printf function writes data to the standard output (stdout) formatted as specified in the format argument.
format |
|
additional |
values for tags in format parameter Depending on the format parameter, the function may expect a sequence of additional arguments, each containing one value to be inserted in place of its corresponding %-tag specified in the format argument. If the format argument contains embedded tags, the tags are substituted with the values of subsequent arguments. There should be the same number of arguments following the format argument as the number of tags that expect a value. |
Tags are formatted as follows:
%[flags][width][.precision][length]specifier
where
% | is the % character, identifying a tag. | ||||||||||||||||||||||||||||||
flags |
consists of formatting flags, as follows:
|
||||||||||||||||||||||||||||||
width |
specifies the minimum number of
characters to be
printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated if the result is larger. If width is *, the width is not specified in the format string, but as an additional integer value argument preceding the argument to be formatted. |
||||||||||||||||||||||||||||||
.precision |
specifies the precision to apply to the corresponding
argument, as follows:
If .precision is .*, the precision is not specified in the format string, but as an additional integer value argument preceding the argument to be formatted. |
||||||||||||||||||||||||||||||
length |
defines the length of the corresponding
argument, as follows:
|
||||||||||||||||||||||||||||||
specifier |
defines the type and the
interpretation of the
value of the corresponding
argument, as follows:
|
On success, the total number of characters written is returned.
On failure, a negative number is returned.
examples | single parameter with no tags | GCC C++ |
Borland C++ Compiler | ||
multiple parameters and tags | GCC C++ | |
Borland C++ Compiler | ||
home | Home Page |