text
stringlengths
0
99.6k
sprintf(s, control [, arg] ...)
char *s, *control;
These functions output optional lists
of arguments according to a format
specified in the null terminated
control string. printf sends output to
the standard output. fprintf sends
output to the specified stream.
sprintf places output in the string s.
sprintf also places a null character
in s after the last output character.
The control string may contain
ordinary characters, which are output,
and conversion specifiers which
specify how an argument is to be
formatted. each conversion specifier
begins with a percent character (%)
and is followed by:
An optional dash (-) which indicates
left adjustment of the argument in the
output field. right adjustment is the
default
An optional number indicating the
minimum field width. a converted
argument will not be fruncated even if
it won't fit in the specified field.
if the first digit of the field width
is zero the field will be padded with
zeros, otherwise it will be padded
with spaces. the maximum width is 64
characters
An optional period (.) followed by a
number indicates the precision for a
float or string argument. for floats
the precision indicates the number of
digits to be printed after the decimal
point (default is six). if the
precision is explicitly zero no
decimal point is printed. for strings
the precision indicates the maximum
number of characters from the string
to be printed (default is the whole
string)
A letter is placed after the percent
(%) conversion specifier indicating
the type of conversion to performed as
follows:
d - an integer argument is printed as
a possibly signed decimal number
u - an integer argument is printed as
an unsigned decimal number
o - an integer argument is printed as
an octal number
x - an integer argument is printed as
an hexadecimal number
f - a float argument is printed
s - a character pointer argument is
assumed to point to a null terminated
string which is printed
c - an integer argument is assumed to
be a character and is printed as such
For each conversion specifier a
corresponding argument of an
appropriate type must be provided.
To output a percent character use %%.
A star (*) may be used in place of
field width or precision. the value
will be taken from an integer
argument.
--------------------------------------
putc, putchar, fputc, putw
- output a character or integer
#include <stdio.h>
putc(c,stream)
char c;
FILE stream;
putchar(c)
char c;
fputc(c,stream)
char c;
FILE stream;
putw(i, stream)
int i;
FILE stream;
Putc and fputc write a character
to the specified stream. Putchar
writes a character to the standard
output. Puts writes an integer to the
specified stream.