std::printf,std::fprintf,std::sprintf,std::snprintf (3) - Linux Manuals
std::printf,std::fprintf,std::sprintf,std::snprintf: std::printf,std::fprintf,std::sprintf,std::snprintf
Command to display std::printf,std::fprintf,std::sprintf,std::snprintf
manual in Linux: $ man 3 std::printf,std::fprintf,std::sprintf,std::snprintf
NAME
std::printf,std::fprintf,std::sprintf,std::snprintf - std::printf,std::fprintf,std::sprintf,std::snprintf
Synopsis
Defined in header <cstdio>
int printf( const char* format, ... ); (1)
int fprintf( std::FILE* stream, const char* format, ... ); (2)
int sprintf( char* buffer, const char* format, ... ); (3)
int snprintf( char* buffer, std::size_t buf_size, const char* format, ... ); (4) (since C++11)
Loads the data from the given locations, converts them to character string equivalents and writes the results to a variety of sinks.
1) Writes the results to stdout.
2) Writes the results to a file stream stream.
3) Writes the results to a character string buffer.
4) Writes the results to a character string buffer. At most buf_size - 1 characters are written. The resulting character string will be terminated with a null character, unless buf_size is zero. If buf_size is zero, nothing is written and buffer may be a null pointer, however the return value (number of bytes that would be written not including the null terminator) is still calculated and returned.
If a call to sprintf or snprintf causes copying to take place between objects that overlap, the behavior is undefined (e.g. sprintf(buf, "%s text", buf);)
Parameters
stream - output file stream to write to
buffer - pointer to a character string to write to
buf_size - up to buf_size - 1 characters may be written, plus the null terminator
pointer to a null-terminated multibyte string specifying how to interpret the data.
The format string consists of ordinary multibyte characters (except %), which are copied unchanged into the output stream, and conversion specifications. Each conversion specification has the following format:
* introductory % character
* (optional) one or more flags that modify the behavior of the conversion:
* -: the result of the conversion is left-justified within the field (by default it is right-justified)
* +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative)
* space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.
* # : alternative form of the conversion is performed. See the table below for exact effects otherwise the behavior is undefined.
* 0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For integer numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present.
* (optional) integer value or * that specifies minimum field width. The result is padded with space characters (by default), if required, on the left when right-justified, or on the right if left-justified. In the case when * is used, the width is specified by an additional argument of type int. If the value of the argument is negative, it results with the - flag specified and positive field width. (Note: This is the minimum width: The value is never truncated.)
* (optional) . followed by integer number or *, or neither that specifies precision of the conversion. In the case when * is used, the precision is specified by an additional argument of type int. If the value of this argument is negative, it is ignored. If neither a number nor * is used, the precision is taken as zero. See the table below for exact effects of precision.
* (optional) length modifier that specifies the size of the argument
* conversion format specifier
The following format specifiers are available: