Line 16... |
Line 16... |
*/
|
*/
|
|
|
/*
|
/*
|
|
|
FUNCTION
|
FUNCTION
|
<<printf>>, <<fprintf>>, <<sprintf>>---format output
|
<<printf>>, <<fprintf>>, <<sprintf>>, <<snprintf>>---format output
|
INDEX
|
INDEX
|
fprintf
|
fprintf
|
INDEX
|
INDEX
|
printf
|
printf
|
INDEX
|
INDEX
|
sprintf
|
sprintf
|
|
INDEX
|
|
snprintf
|
|
|
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
#include <stdio.h>
|
#include <stdio.h>
|
|
|
int printf(const char *<[format]> [, <[arg]>, ...]);
|
int printf(const char *<[format]> [, <[arg]>, ...]);
|
int fprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
|
int fprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
|
int sprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
|
int sprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
|
|
int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]);
|
|
|
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
#include <stdio.h>
|
#include <stdio.h>
|
|
|
int printf(<[format]> [, <[arg]>, ...])
|
int printf(<[format]> [, <[arg]>, ...])
|
Line 45... |
Line 48... |
|
|
int sprintf(<[str]>, <[format]> [, <[arg]>, ...]);
|
int sprintf(<[str]>, <[format]> [, <[arg]>, ...]);
|
char *<[str]>;
|
char *<[str]>;
|
char *<[format]>;
|
char *<[format]>;
|
|
|
|
int snprintf(<[str]>, size_t <[size]>, <[format]> [, <[arg]>, ...]);
|
|
char *<[str]>;
|
|
size_t <[size]>;
|
|
char *<[format]>;
|
|
|
DESCRIPTION
|
DESCRIPTION
|
<<printf>> accepts a series of arguments, applies to each a
|
<<printf>> accepts a series of arguments, applies to each a
|
format specifier from <<*<[format]>>>, and writes the
|
format specifier from <<*<[format]>>>, and writes the
|
formatted data to <<stdout>>, terminated with a null character.
|
formatted data to <<stdout>>, terminated with a null character.
|
The behavior of <<printf>> is undefined if there are not enough
|
The behavior of <<printf>> is undefined if there are not enough
|
arguments for the format.
|
arguments for the format.
|
<<printf>> returns when it reaches the end of the format string.
|
<<printf>> returns when it reaches the end of the format string.
|
If there are more arguments than the format requires, excess
|
If there are more arguments than the format requires, excess
|
arguments are ignored.
|
arguments are ignored.
|
|
|
<<fprintf>> and <<sprintf>> are identical to <<printf>>, other than the
|
<<fprintf>>, <<sprintf>> and <<snprintf>> are identical to <<printf>>,
|
destination of the formatted output: <<fprintf>> sends the
|
other than the destination of the formatted output: <<fprintf>> sends
|
output to a specified file <[fd]>, while <<sprintf>> stores the
|
the output to a specified file <[fd]>, while <<sprintf>> stores the
|
output in the specified char array <[str]>. For <<sprintf>>,
|
output in the specified char array <[str]> and <<snprintf>> limits
|
the behavior is also undefined if the output <<*<[str]>>>
|
number of characters written to <[str]> to at most <[size]> (including
|
overlaps with one of the arguments.
|
terminating <<0>>). For <<sprintf>> and <<snprintf>>, the behavior is
|
<[format]> is a pointer to a charater string containing two types of
|
also undefined if the output <<*<[str]>>> overlaps with one of the
|
objects: ordinary characters (other than <<%>>), which are
|
arguments. <[format]> is a pointer to a charater string containing
|
copied unchanged to the output, and conversion
|
two types of objects: ordinary characters (other than <<%>>), which
|
|
are copied unchanged to the output, and conversion
|
specifications, each of which is introduced by <<%>>.
|
specifications, each of which is introduced by <<%>>.
|
(To include <<%>> in the output, use <<%%>> in the format string.)
|
(To include <<%>> in the output, use <<%%>> in the format string.)
|
A conversion specification has the following form:
|
A conversion specification has the following form:
|
|
|
. %[<[flags]>][<[width]>][.<[prec]>][<[size]>][<[type]>]
|
. %[<[flags]>][<[width]>][.<[prec]>][<[size]>][<[type]>]
|