Write text in specified format to array
int __far vsnprintf(char __far * restrict s, size_t n, const char __far * restrict format, va_list arg); (C99)
The number of characters that were output (excluding the null character (\0)) is returned.
Returns EOF(-1) if a write error has occurred.
From among the parameter sequence, this function writes the parameter indicated by pointer arg to the array indicated by s. The conversion method in this case complies with the format specified by the string indicated by format. When n is 0, no text is written and s may be a null pointer. In other cases, output characters subsequent to the (n-1)th character are discarded without being written to the array and the null character is written after the character string that was actually written to the array. When copying is executed between objects whose areas overlap, correct operation is not guaranteed.
Correct operation is not guaranteed if there is not enough arguments to satisfy the format. If the format becomes full even though arguments are still left, the extra arguments are merely evaluated and they will be ignored.
The format consists of 0 or more directives. The format will be output without change except for a conversion specification starting with %. The conversion specification fetches the 0 or more subsequent arguments, converts them, and then outputs them.
The format consists of the following two types of directives:
Characters that are copied directly without conversion (other than "%"). |
|
Specifications that fetch zero or more arguments and assign a specification. |
Each conversion specification begins with character "%" (to insert "%" in the output, specify "%%" in the format string). The following appear after the "%":
%[flag][field-width][precision][size][type-specification-character]
The meaning of each conversion specification is explained below.
Zero or more flags, which qualify the meaning of the conversion specification, are placed in any order.
The flag characters and their meanings are as follows:
This is an optional minimum field width.
If the converted value is smaller than this field width, the left side is filled with spaces (if the left justification flag explained above is assigned, the right side will be filled with spaces). This field width takes the form of "*" or a decimal integer. If "*" is specified, an int type argument is used as the field width. A negative field width is not supported. If an attempt is made to specify a negative field width, it is interpreted as a minus (-) flag appended to the beginning of a positive field width.
For d, i, o, u, x, or X conversion, the value assigned for the precision is the minimum number of digits to appear. For e, f, E, or F conversion, it is the number of digits to appear after the decimal point. For g or G conversion, it is the maximum number of significant digits. For s conversion, it is the maximum number of bytes.
The precision takes the form of "*" or "." followed by a decimal integer. If "*" is specified, an int type argument is used as the precision. If a negative precision is specified, it is treated as if the precision were omitted. If only "." is specified, the precision is assumed to be 0. If the precision appears together with a conversion specification other than the above, the operation is undefined.
This is an arbitrary optional size character hh, h, l, ll, j, z, t, or L, which changes the default method for interpreting the data type of the corresponding argument.
When hh is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a signed char or unsigned char argument. hh also causes a following n type specification to be forcibly applied to a pointer to a signed char argument. (C99)
When h is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a short int or unsigned short int argument. h is also causes a following n type specification to be forcibly applied to a pointer to short argument.
When l is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a long or unsigned long argument. l is also causes a following n type specification to be forcibly applied to a pointer to long argument.
When ll is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a long long or unsigned long long argument. Furthermore, for ll, a following n type specification is forcibly applied to a long long pointer.
When j is specified, a following d, i, o, u, x, or X type specification is forcibly applied to an intmax_t or uintmax_t argument. j also causes a following n type specification to be forcibly applied to a pointer to an intmax_t argument. (C99)
When z is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a size_t or signed int argument. z also causes a following n type specification to be forcibly applied to a pointer to a signed int argument. (C99)
When t is specified, a following d, i, o, u, x, or X type specification is forcibly applied to a ptrdiff_t or unsigned int argument. t also causes a following n type specification to be forcibly applied to a pointer to a ptrdiff_t argument. (C99)
When L is specified, a following e, E, f, F, g, or G type specification is forcibly applied to a long double argument. However, since the double type and long double type have the same format in this compiler, the specification has no effect.
These are characters that specify the type of conversion that is to be applied.
The characters that specify conversion types and their meanings are as follows.
F conversion can only be specified for C99 libraries.
a conversion or A conversion of the C99 standard is not supported.