3 fprintf, printf, sprintf, snprintf, vfprintf, vprintf, vsprintf, vsnprintf \- print formatted output
10 int fprintf(FILE *f, char *format, ...)
13 int printf(char *format, ...)
16 int sprintf(char *s, char *format, ...)
19 int snprintf(char *s, int n, char *format, ...)
22 int vfprintf(FILE *f, char *format, va_list args)
25 int vprintf(char *format, va_list args)
28 int vsprintf(char *s, char *format, va_list args)
31 int vsnprintf(char *s, int n, char *format, va_list args)
34 places output on the named output stream
39 places output on the standard output stream
43 followed by the null character
45 in consecutive bytes starting at
47 it is the user's responsibility to ensure that
48 enough storage is available.
54 bytes (including the null character)
62 are the same, except the
64 argument is the argument list of the
65 calling function, and the effect is as if the calling function's
66 argument list from that point on is passed to the
70 Each function returns the number of characters
71 transmitted (not including the
77 a negative value if an output error was encountered.
80 convert, format, and print their
87 contains two types of objects:
88 plain characters, which are simply copied to the
90 and conversion specifications,
91 each of which results in fetching of
94 The results are undefined if there are arguments of the
96 arguments for the format.
97 If the format is exhausted while
98 arguments remain, the excess
101 Each conversion specification is introduced by
112 which modify the meaning of
113 the conversion specification.
115 An optional decimal digit string specifying a minimum
117 If the converted value has fewer characters
118 than the field width, it will be padded with spaces on the
119 left (or right, if the left adjustment, described later, has been given)
125 the minimum number of digits to appear for the
134 the number of digits to appear after the
135 decimal point for the
141 the maximum number of significant digits
147 or the maximum number of characters
148 to be written from a string in
151 The precision takes the form of a period
153 followed by an optional decimal integer;
154 if the integer is omitted, it is treated as zero.
158 specifying that a following
166 conversion specifier applies to a
172 argument (the argument will have been promoted according to the integral
173 promotions, and its value shall be converted to
181 specifying that a following
183 conversion specifier applies to a pointer to a
188 (ell) specifying that a following
196 conversion character applies to a
204 specifying that a following
206 conversion specifier applies to a pointer to a
212 specifying that a following
219 conversion specifier applies to a
227 appears with any other conversion specifier, the behavior is undefined.
229 A character that indicates the type of
230 conversion to be applied.
233 A field width or precision, or both, may be
234 indicated by an asterisk
236 instead of a digit string.
241 the field width or precision.
242 The arguments specifying field width or precision, or both,
243 shall appear (in that order) before the argument (if any) to be converted.
244 A negative field width argument is taken as a
246 flag followed by a positive field width.
247 A negative precision is taken as if it were missing.
249 The flag characters and their meanings are:
253 The result of the conversion is left-justified within the field.
256 The result of a signed
257 conversion always begins with a sign
263 If the first character of a signed conversion is not a sign,
264 or a signed conversion results in no characters,
266 is prefixed to the result.
267 This implies that if the blank and
269 flags both appear, the blank flag is ignored.
272 The result is to be converted
273 to an ``alternate form.''
276 conversion, it increases the precision to force
277 the first digit of the result to be a zero.
282 conversion, a non-zero result has
294 conversions, the result always contains a decimal point,
295 even if no digits follow the point (normally, a decimal point
296 appears in the result of these conversions only if a digit
302 conversions, trailing zeros are
304 be removed from the result
305 as they normally are.
306 For other conversions, the behavior is undefined.
322 conversions, leading zeros (following any indication of sign or base)
323 are used to pad the field width; no space padding is performed.
328 flags both appear, the
330 flag will be ignored.
339 conversions, if a precision is specified, the
341 flag will be ignored.
342 For other conversions, the behavior is undefined.
345 The conversion characters
346 and their meanings are:
350 \fLd\fP,\fLo\fP,\fLu\fP,\fLx\fP,\fLX\fP
353 is converted to signed decimal
361 or unsigned hexadecimal notation
369 conversion and the letters
374 The precision specifies the minimum number of digits
375 to appear; if the value being converted can be represented
376 in fewer digits, it is expanded with leading zeros.
377 The default precision is 1.
378 The result of converting a zero value with a precision
379 of zero is no characters.
384 argument is converted to decimal notation
386 [\-]\fIddd\fL.\fIddd\fR,
387 where the number of digits after the decimal point
388 is equal to the precision specification.
392 if the precision is explicitly
394 no decimal point appears.
399 argument is converted in the style
400 [\-]\fId\fL.\fIddd\fLe\fRĀ±\fIdd\fR,
401 where there is one digit before the decimal point and
402 the number of digits after it is equal to the
404 when the precision is missing, it is taken as 6;
405 if the precision is zero, no decimal point appears.
408 format code produces a number with
412 introducing the exponent.
413 The exponent always contains at least two digits.
418 argument is printed in style
426 conversion specifier),
427 with the precision specifying the number of significant digits.
428 If an explicit precision is zero, it is taken as 1.
429 The style used depends on the value converted:
432 is used only if the exponent resulting from
433 the conversion is less than \-4
434 or greater than or equal to the precision.
435 Trailing zeros are removed from the fractional portion of the result;
436 a decimal point appears only if it is followed by a digit.
441 argument is converted to an
444 and the resulting character is written.
448 argument is taken to be a string (character pointer)
449 and characters from the string are printed until
453 the number of characters indicated by the precision
454 specification is reached.
455 If the precision is missing, it is taken to be infinite, so
456 all characters up to the first null character are printed.
460 the argument yields undefined results.
465 argument is printed in an implementation-defined way (for Plan 9:
466 the address as hexadecimal number).
469 The argument shall be a pointer to an integer into which is
471 the number of characters written to the output stream so far by
474 No argument is converted.
479 no argument is converted.
482 If a conversion specification is invalid, the behavior is undefined.
484 If any argument is, or points to, a union or an aggregate
485 (except for an array of character type using
487 conversion, or a pointer cast to be a pointer to
491 conversion), the behavior is undefined.
493 In no case does a nonexistent or small field width cause truncation
494 of a field; if the result of a conversion is wider than the field width,
495 the field is expanded to contain the conversion result.
503 There is no way to print a wide character (rune); use