Description | These functions are used to format output. fwprintf() prepares the arguments in arglist according to the specifications in the wide character string format and writes them to the file pointed to by the file pointer dz. fwprintf() returns when the end of format is reached.
vwprintf() is the same as the fwprintf() function with dz = stdout where the argument list is replaced by an argument of type va_list that must have been initialized by the va_start macro (possibly followed by va_arg calls). The function does not call the va_end macro.
wprintf() is the same as the fwprintf() function with dz = stdout .
swprintf() writes formatted output to the wide character string s. Otherwise swprintf() is the same as the fwprintf() function. A maximum of n wide characters are written, including the closing null character that is automatically appended when n > 0.
vfwprintf() is the same as the fwprintf() function where the argument list is replaced by an argument of type va_list that must have been initialized by the va_start macro (possibly followed by va_arg calls). The function does not call the va_end macro.
vswprintf() is the same as the swprintf() function where the argument list is replaced by an argument of type va_list that must have been initialized by the va_start macro (possibly followed by va_arg calls). The function does not call the va_end macro.
format is a wide character string composed of zero or more directives and wide characters: conversion specifications beginning with the percent character (% ), each of which is associated with zero or more arguments in arglist. The results are undefined if fewer arguments are passed in arglist than are defined in format. If the number of arguments defined in format is greater than the arguments passed in arglist, the excess arguments are ignored. The arguments assigned to a directive are converted, formatted and written to the output stream according to the directive. Characters of type wchar_t (but not %) that can be copied directly to the output as is. white-space characters (see section “White-space characters”).
Each conversion specification is introduced by the % character, after which the following appear in sequence: Zero or more flags, which modify the meaning of the conversion specification. An optional non-zero decimal number or an asterisk (*) that specifies a minimum field width. If the converted value has fewer bytes than the field width, it will be padded to the field width with spaces on the left (or padded on the right if the left-adjustment flag "-" was specified). An optional precision that gives the minimum number of digits to appear for the d , i , o , u , x and X conversions; the number of digits to appear after the radix character for the e , E and f conversions; the maximum number of significant digits for the g and G conversions or the maximum number of bytes to be printed from a string in s conversion. The precision takes the form of a period (.), followed by a decimal digit string or an asterisk (*), where a null digit string (only “.” specified) is treated as 0. An optional size modifier hh , h , l , ll , L , j , z oder t preceding a conversion character: l before c means that an argument of type wint_t is to be converted;
l before s : means that an argument of type wchar_t (pointer to a wide character) is to be converted;
hh before d , i , o , u , x or X : conversion of an argument of type char or unsigned char (the argument is extended according to the integer extension and its value is converted to a char or unsigned char before output);
hh before n : conversion of an argument of type pointer to char ; h before d , i , o , u , x or X : conversion of an argument of type short int or unsigned short int (the argument is extended according to the integer extension and its value is converted to a short int or unsigned short int before output);
h before n : conversion of an argument of type pointer to short int ;
l before d , i , o , u , x or X : conversion of an argument of type long int or unsigned long int ;
l before n : conversion of an argument of type pointer to long int ;
ll before d , i , o , u , x or X : conversion of an argument of type long long int or unsigned long long int ;
ll before n : conversion of an argument of type pointer to long long int ;
j before d , i , o , u , x oder X : conversion of an argument of type intmax _t oder uintmax_t ;
j before n : conversion of an argument of type pointer to intmax_t ;
z before d , i , o , u , x oder X : conversion of an argument of type long int oder size_t ;
z before n : conversion of an argument of type pointer to long int ;
t before d , i , o , u , x oder X : conversion of an argument of type ptrdiff_t oder unsigned long int;
t before n : conversion of an argument of type pointer to ptrdiff_t ;
L before a , A , e , E , f , F , g or G : conversion of an argument of type long double .
If hh , h , l , ll , L , j , z or t appears before any other conversion character, the behavior is undefined. A conversion character of type wchar_t that specifies the type of conversion to be applied (see the list below).
A field width, or precision, or both, may be indicated by an asterisk ( *). In this case the values are obtained from the argument list instead of from the format specification. The (integer) values specifying the field width, precision or both must appear in that order before the argument, if any, to be converted. A negative field width is taken as a "-" flag followed by a positive field width. A negative precision is taken as if the precision were omitted. Conversion specifications have the following structure: %
| [-][+]['BLANK'][#][0] | [ n |*]
| [. m |.*]
| {[{hh|h|l|ll|j|z|t}] {d|i|o|u|x|X} |
[{hh|h|l|ll|j|z|t}] n |
[L] {a|A|e|E|f|F|g|G} |
[l] {c|s} |
{D|O|U|C|S|p} |
% } | 1. | 2. | 3. | 4 . | 5. |
Start of a conversion specification Flags Field width Precision Characters that define the actual conversion
-
| The result of the conversion will be left-justified within the array. | +
| The result of a signed conversion will always begin with a sign (+ or -). | 'BLANK' | If the first wide character of a signed conversion is not a sign or the result of a signed conversion is not a wide character, a space will be prefixed to the result. This means that if the space and + flags both appear, the space flag will be ignored. | #
| This flag specifies that the value is to be converted to an alternative form. This flag has no effect for c , d , i , s and -. For o conversion, it increases the precision to force the first digit of the result to be 0. For x or X conversions, a non-zero result will have the string "0x" (or "0X" ) prefixed to it. For e , E , f , g or G conversions, the result will always contain a wide radix character, even if no digits follow the radix character. Without this flag, a radix character appears in the result of these conversions only if a digit follows it. For g and G conversions, trailing zeros will not be removed from the result as they normally are. For other conversions, the behavior is undefined. | 0
| For d , i , o , u , x , X , e , E , f , g and G conversions, leading zeros (following any indication of sign or base) are used to pad to the array width; no space padding is performed. If the 0 and - flags both appear, the 0 flag will be ignored. For d , i , o , u , x and X conversions, if a precision is specified, the 0 flag will be ignored. For other conversions, the behavior is undefined. | n | Minimum field width (including radix character). If more positions are required for the conversion of a number, this specification has no effect. If the output is shorter than the specified field width, it is padded with blanks or zeros up to the field width (see flags - and 0). | *
| The total field width (see n) is defined by an argument instead of a conversion specification. The current (integral) value must immediately precede the argument to be converted or the value of the precision specification (flag .m) in the argument list (delimited by a comma). | . m
| Precision specification. d , i , o , u , x resp. X conversions: minimal number of digits to be output. Defaulit: 1.
e -, E -, f , F conversions: exact number of positions after the radix character. Default: 6 positions.
a , A conversions: exact number of positions after the radix character. Default: 13 positions for long , 27 positions for long double .
g resp. G conversions: maximum number of significant positions.
s conversion: maximum number of characters to be output. Default: all characters up to the terminating null byte. The precision specification is ignored for all other conversions.
| .*
| The precision (see .m) is defined by an argument instead of a conversion specification. The current (integral) value must immediately precede the argument to be converted in the argument list (delimited by a comma). |
Conversion characters d , i
| The int argument is converted to a signed decimal in the style [-]dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it will be expanded with leading zeros. The default precision is 1. The result of converting 0 with an explicit precision of 0 is no characters. | o , u
| The unsigned int argument is converted to unsigned octal format (o) or in an unsigned decimal number (u) in the style dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it will be expanded with leading zeros. The default precision is 1. The result of converting 0 with an explicit precision of 0 is no characters. | x , X
| The unsigned int argument is converted to unsigned hexadecimal format in the style dddd; the letters abcdef (for x ) or ABCDEF (for X ) are used in addition to the digits. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it will be expanded with leading zeros. The default precision is 1. The result of converting 0 with an explicit precision of 0 is no characters. | f , F
| The double argument is converted to decimal notation in the style [-] ddd. ddd, where the number of digits after the radix character is equal to the precision specification. If the precision is missing, it is taken as 6. If the precision is explicitly 0 and no # flag is present, no radix character appears. If a radix character appears, at least one digit appears before it. The value is rounded to the appropriate number of digits. | e , E
| The double argument is converted in the style [-] d.ddde+-dd, where there is one digit before the radix character (which is non-zero if the argument is non-zero) and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6. If the precision is 0 and no # flag is present, no radix character appears. The value is rounded to the appropriate number of digits. The E conversion character will produce a number with E instead of e introducing the exponent. The exponent always contains at least two digits. If the value is 0, the exponent is 0. | g , G
| The double argument is converted in the style f or e (or in the style E in the case of a G conversion character), with the precision specifying the number of significant digits. If an explicit precision is 0, it is taken as 1. The style used depends on the value converted; style e (or E ) will be used only if the exponent resulting from such a conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional portion of the result; a radix character appears only if it is followed by a digit. | a , A
| The double argument (float oder double ) is converted in the style[-] 0xh.hhhh p{+|-} d. Each h represents a hexadecimal digit. The radix character is determined by the locale (category LC_NUMERIC ). The default is a period. The exponent is printed to base 2. The a conversion character will produce a number with lowercase letters a , b , c , d , e , f , x and p , the A conversion character a number with uppercase letters A , B, C , D , E , F , X and P . The number of positions after the radix character depends on the precision specified in .m; the default is 27 positions if used together with the conversion character L, 13 otherwise. If the precision is set to 0, the output will include the output will have no radix character. | c
| If the character “l” precedes it, the argument is converted from type wint_t to type wchar_t , the resulting character is written. If not preceded by a l , the argument is converted from type int to a wide character, just like for the btowc() function call. The resulting character is written. | s
| If not preceded by a l , the argument is of type pointer to a char array. Characters in the array are converted in the same manner as when the mbrtowc() function is called. The conversion status is written to an object of type mbstate_t and initialized to 0 before the first multi-byte character is converted. Data is written up to the terminating null character (and only to there). If preceded by a l , the argument is of type pointer to a wchar_t array. Wide characters from the array are written up to the terminating null character (and only to there). If a precision m is specified, no more than m bytes are written. If the precision is not specified or is greater than the size of the array, the array must contain a wide character null byte (as a terminator). | S
| Same as ls . | C
| Same as lc . | p
| The argument must be a pointer to void . The value is output as an 8-digit hexadecimal number. | n
| The argument must be a pointer to int into which is written the number of bytes written to the output so far by this call to one of the fwprintf functions. No argument is converted. | %
| The wide character % is output; no argument is converted. The complete conversion specification must be of the form %%. |
If the character that follows % is not a valid conversion character, the result of the conversion is undefined. If an argument is a UNION or a pointer to a UNION , the result of the conversion is undefined. The same applies when an argument is an array or a pointer to an array, except for the following three cases: The argument is an array of type char and uses %s , the argument is an array of type wchar_t and uses %ls or the argument is a pointer and uses %p . A non-existent array width or a missing array width will never result in the truncation of an array. If the result of a conversion is wider than the array width, the array is simply extended to accept the output. |