xref: /freebsd/lib/libc/stdio/printf.3 (revision d876124d6ae9d56da5b4ff4c6015efd1d0c9222a)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)printf.3	8.1 (Berkeley) 6/4/93
33.\" $FreeBSD$
34.\"
35.Dd October 16, 2004
36.Dt PRINTF 3
37.Os
38.Sh NAME
39.Nm printf , fprintf , sprintf , snprintf , asprintf ,
40.Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf
41.Nd formatted output conversion
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In stdio.h
46.Ft int
47.Fn printf "const char * restrict format" ...
48.Ft int
49.Fn fprintf "FILE * restrict stream" "const char * restrict format" ...
50.Ft int
51.Fn sprintf "char * restrict str" "const char * restrict format" ...
52.Ft int
53.Fn snprintf "char * restrict str" "size_t size" "const char * restrict format" ...
54.Ft int
55.Fn asprintf "char **ret" "const char *format" ...
56.In stdarg.h
57.Ft int
58.Fn vprintf "const char * restrict format" "va_list ap"
59.Ft int
60.Fn vfprintf "FILE * restrict stream" "const char * restrict format" "va_list ap"
61.Ft int
62.Fn vsprintf "char * restrict str" "const char * restrict format" "va_list ap"
63.Ft int
64.Fn vsnprintf "char * restrict str" "size_t size" "const char * restrict format" "va_list ap"
65.Ft int
66.Fn vasprintf "char **ret" "const char *format" "va_list ap"
67.Sh DESCRIPTION
68The
69.Fn printf
70family of functions produces output according to a
71.Fa format
72as described below.
73The
74.Fn printf
75and
76.Fn vprintf
77functions
78write output to
79.Dv stdout ,
80the standard output stream;
81.Fn fprintf
82and
83.Fn vfprintf
84write output to the given output
85.Fa stream ;
86.Fn sprintf ,
87.Fn snprintf ,
88.Fn vsprintf ,
89and
90.Fn vsnprintf
91write to the character string
92.Fa str ;
93and
94.Fn asprintf
95and
96.Fn vasprintf
97dynamically allocate a new string with
98.Xr malloc 3 .
99.Pp
100These functions write the output under the control of a
101.Fa format
102string that specifies how subsequent arguments
103(or arguments accessed via the variable-length argument facilities of
104.Xr stdarg 3 )
105are converted for output.
106.Pp
107These functions return the number of characters printed
108(not including the trailing
109.Ql \e0
110used to end output to strings) or a negative value if an output error occurs,
111except for
112.Fn snprintf
113and
114.Fn vsnprintf ,
115which return the number of characters that would have been printed if the
116.Fa size
117were unlimited
118(again, not including the final
119.Ql \e0 ) .
120.Pp
121The
122.Fn asprintf
123and
124.Fn vasprintf
125functions
126set
127.Fa *ret
128to be a pointer to a buffer sufficiently large to hold the formatted string.
129This pointer should be passed to
130.Xr free 3
131to release the allocated storage when it is no longer needed.
132If sufficient space cannot be allocated,
133.Fn asprintf
134and
135.Fn vasprintf
136will return \-1 and set
137.Fa ret
138to be a
139.Dv NULL
140pointer.
141.Pp
142The
143.Fn snprintf
144and
145.Fn vsnprintf
146functions
147will write at most
148.Fa size Ns \-1
149of the characters printed into the output string
150(the
151.Fa size Ns 'th
152character then gets the terminating
153.Ql \e0 ) ;
154if the return value is greater than or equal to the
155.Fa size
156argument, the string was too short
157and some of the printed characters were discarded.
158The output is always null-terminated.
159.Pp
160The
161.Fn sprintf
162and
163.Fn vsprintf
164functions
165effectively assume an infinite
166.Fa size .
167.Pp
168The format string is composed of zero or more directives:
169ordinary
170.\" multibyte
171characters (not
172.Cm % ) ,
173which are copied unchanged to the output stream;
174and conversion specifications, each of which results
175in fetching zero or more subsequent arguments.
176Each conversion specification is introduced by
177the
178.Cm %
179character.
180The arguments must correspond properly (after type promotion)
181with the conversion specifier.
182After the
183.Cm % ,
184the following appear in sequence:
185.Bl -bullet
186.It
187An optional field, consisting of a decimal digit string followed by a
188.Cm $ ,
189specifying the next argument to access.
190If this field is not provided, the argument following the last
191argument accessed will be used.
192Arguments are numbered starting at
193.Cm 1 .
194If unaccessed arguments in the format string are interspersed with ones that
195are accessed the results will be indeterminate.
196.It
197Zero or more of the following flags:
198.Bl -tag -width ".So \  Sc (space)"
199.It Sq Cm #
200The value should be converted to an
201.Dq alternate form .
202For
203.Cm c , d , i , n , p , s ,
204and
205.Cm u
206conversions, this option has no effect.
207For
208.Cm o
209conversions, the precision of the number is increased to force the first
210character of the output string to a zero (except if a zero value is printed
211with an explicit precision of zero).
212For
213.Cm x
214and
215.Cm X
216conversions, a non-zero result has the string
217.Ql 0x
218(or
219.Ql 0X
220for
221.Cm X
222conversions) prepended to it.
223For
224.Cm a , A , e , E , f , F , g ,
225and
226.Cm G
227conversions, the result will always contain a decimal point, even if no
228digits follow it (normally, a decimal point appears in the results of
229those conversions only if a digit follows).
230For
231.Cm g
232and
233.Cm G
234conversions, trailing zeros are not removed from the result as they
235would otherwise be.
236.It So Cm 0 Sc (zero)
237Zero padding.
238For all conversions except
239.Cm n ,
240the converted value is padded on the left with zeros rather than blanks.
241If a precision is given with a numeric conversion
242.Cm ( d , i , o , u , i , x ,
243and
244.Cm X ) ,
245the
246.Cm 0
247flag is ignored.
248.It Sq Cm \-
249A negative field width flag;
250the converted value is to be left adjusted on the field boundary.
251Except for
252.Cm n
253conversions, the converted value is padded on the right with blanks,
254rather than on the left with blanks or zeros.
255A
256.Cm \-
257overrides a
258.Cm 0
259if both are given.
260.It So "\ " Sc (space)
261A blank should be left before a positive number
262produced by a signed conversion
263.Cm ( a , A , d , e , E , f , F , g , G ,
264or
265.Cm i ) .
266.It Sq Cm +
267A sign must always be placed before a
268number produced by a signed conversion.
269A
270.Cm +
271overrides a space if both are used.
272.It Sq Cm '
273Decimal conversions
274.Cm ( d , u ,
275or
276.Cm i )
277or the integral portion of a floating point conversion
278.Cm ( f
279or
280.Cm F )
281should be grouped and separated by thousands using
282the non-monetary separator returned by
283.Xr localeconv 3 .
284.El
285.It
286An optional decimal digit string specifying a minimum field width.
287If the converted value has fewer characters than the field width, it will
288be padded with spaces on the left (or right, if the left-adjustment
289flag has been given) to fill out
290the field width.
291.It
292An optional precision, in the form of a period
293.Cm \&.
294followed by an
295optional digit string.
296If the digit string is omitted, the precision is taken as zero.
297This gives the minimum number of digits to appear for
298.Cm d , i , o , u , x ,
299and
300.Cm X
301conversions, the number of digits to appear after the decimal-point for
302.Cm a , A , e , E , f ,
303and
304.Cm F
305conversions, the maximum number of significant digits for
306.Cm g
307and
308.Cm G
309conversions, or the maximum number of characters to be printed from a
310string for
311.Cm s
312conversions.
313.It
314An optional length modifier, that specifies the size of the argument.
315The following length modifiers are valid for the
316.Cm d , i , n , o , u , x ,
317or
318.Cm X
319conversion:
320.Bl -column ".Cm q Em (deprecated)" ".Vt signed char" ".Vt unsigned long long" ".Vt long long *"
321.It Sy Modifier Ta Cm d , i Ta Cm o , u , x , X Ta Cm n
322.It Cm hh Ta Vt "signed char" Ta Vt "unsigned char" Ta Vt "signed char *"
323.It Cm h Ta Vt short Ta Vt "unsigned short" Ta Vt "short *"
324.It Cm l No (ell) Ta Vt long Ta Vt "unsigned long" Ta Vt "long *"
325.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *"
326.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
327.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
328.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
329.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
330.El
331.Pp
332Note:
333the
334.Cm t
335modifier, when applied to a
336.Cm o , u , x ,
337or
338.Cm X
339conversion, indicates that the argument is of an unsigned type
340equivalent in size to a
341.Vt ptrdiff_t .
342The
343.Cm z
344modifier, when applied to a
345.Cm d
346or
347.Cm i
348conversion, indicates that the argument is of a signed type equivalent in
349size to a
350.Vt size_t .
351Similarly, when applied to an
352.Cm n
353conversion, it indicates that the argument is a pointer to a signed type
354equivalent in size to a
355.Vt size_t .
356.Pp
357The following length modifier is valid for the
358.Cm a , A , e , E , f , F , g ,
359or
360.Cm G
361conversion:
362.Bl -column ".Sy Modifier" ".Cm a , A , e , E , f , F , g , G"
363.It Sy Modifier Ta Cm a , A , e , E , f , F , g , G
364.It Cm l No (ell) Ta Vt double
365(ignored, same behavior as without it)
366.It Cm L Ta Vt "long double"
367.El
368.Pp
369The following length modifier is valid for the
370.Cm c
371or
372.Cm s
373conversion:
374.Bl -column ".Sy Modifier" ".Vt wint_t" ".Vt wchar_t *"
375.It Sy Modifier Ta Cm c Ta Cm s
376.It Cm l No (ell) Ta Vt wint_t Ta Vt "wchar_t *"
377.El
378.It
379A character that specifies the type of conversion to be applied.
380.El
381.Pp
382A field width or precision, or both, may be indicated by
383an asterisk
384.Ql *
385or an asterisk followed by one or more decimal digits and a
386.Ql $
387instead of a
388digit string.
389In this case, an
390.Vt int
391argument supplies the field width or precision.
392A negative field width is treated as a left adjustment flag followed by a
393positive field width; a negative precision is treated as though it were
394missing.
395If a single format directive mixes positional
396.Pq Li nn$
397and non-positional arguments, the results are undefined.
398.Pp
399The conversion specifiers and their meanings are:
400.Bl -tag -width ".Cm diouxX"
401.It Cm diouxX
402The
403.Vt int
404(or appropriate variant) argument is converted to signed decimal
405.Cm ( d
406and
407.Cm i ) ,
408unsigned octal
409.Pq Cm o ,
410unsigned decimal
411.Pq Cm u ,
412or unsigned hexadecimal
413.Cm ( x
414and
415.Cm X )
416notation.
417The letters
418.Dq Li abcdef
419are used for
420.Cm x
421conversions; the letters
422.Dq Li ABCDEF
423are used for
424.Cm X
425conversions.
426The precision, if any, gives the minimum number of digits that must
427appear; if the converted value requires fewer digits, it is padded on
428the left with zeros.
429.It Cm DOU
430The
431.Vt "long int"
432argument is converted to signed decimal, unsigned octal, or unsigned
433decimal, as if the format had been
434.Cm ld , lo ,
435or
436.Cm lu
437respectively.
438These conversion characters are deprecated, and will eventually disappear.
439.It Cm eE
440The
441.Vt double
442argument is rounded and converted in the style
443.Sm off
444.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd
445.Sm on
446where there is one digit before the
447decimal-point character
448and the number of digits after it is equal to the precision;
449if the precision is missing,
450it is taken as 6; if the precision is
451zero, no decimal-point character appears.
452An
453.Cm E
454conversion uses the letter
455.Ql E
456(rather than
457.Ql e )
458to introduce the exponent.
459The exponent always contains at least two digits; if the value is zero,
460the exponent is 00.
461.Pp
462For
463.Cm a , A , e , E , f , F , g ,
464and
465.Cm G
466conversions, positive and negative infinity are represented as
467.Li inf
468and
469.Li -inf
470respectively when using the lowercase conversion character, and
471.Li INF
472and
473.Li -INF
474respectively when using the uppercase conversion character.
475Similarly, NaN is represented as
476.Li nan
477when using the lowercase conversion, and
478.Li NAN
479when using the uppercase conversion.
480.It Cm fF
481The
482.Vt double
483argument is rounded and converted to decimal notation in the style
484.Sm off
485.Oo \- Oc Ar ddd Li \&. Ar ddd ,
486.Sm on
487where the number of digits after the decimal-point character
488is equal to the precision specification.
489If the precision is missing, it is taken as 6; if the precision is
490explicitly zero, no decimal-point character appears.
491If a decimal point appears, at least one digit appears before it.
492.It Cm gG
493The
494.Vt double
495argument is converted in style
496.Cm f
497or
498.Cm e
499(or
500.Cm F
501or
502.Cm E
503for
504.Cm G
505conversions).
506The precision specifies the number of significant digits.
507If the precision is missing, 6 digits are given; if the precision is zero,
508it is treated as 1.
509Style
510.Cm e
511is used if the exponent from its conversion is less than \-4 or greater than
512or equal to the precision.
513Trailing zeros are removed from the fractional part of the result; a
514decimal point appears only if it is followed by at least one digit.
515.It Cm aA
516The
517.Vt double
518argument is rounded and converted to hexadecimal notation in the style
519.Sm off
520.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d ,
521.Sm on
522where the number of digits after the hexadecimal-point character
523is equal to the precision specification.
524If the precision is missing, it is taken as enough to represent
525the floating-point number exactly, and no rounding occurs.
526If the precision is zero, no hexadecimal-point character appears.
527The
528.Cm p
529is a literal character
530.Ql p ,
531and the exponent consists of a positive or negative sign
532followed by a decimal number representing an exponent of 2.
533The
534.Cm A
535conversion uses the prefix
536.Dq Li 0X
537(rather than
538.Dq Li 0x ) ,
539the letters
540.Dq Li ABCDEF
541(rather than
542.Dq Li abcdef )
543to represent the hex digits, and the letter
544.Ql P
545(rather than
546.Ql p )
547to separate the mantissa and exponent.
548.Pp
549Note that there may be multiple valid ways to represent floating-point
550numbers in this hexadecimal format.
551For example,
552.Li 0x1.92p+1 , 0x3.24p+0 , 0x6.48p-1 ,
553and
554.Li 0xc.9p-2
555are all equivalent.
556.Fx 8.0
557and later always prints finite non-zero numbers using
558.Ql 1
559as the digit before the hexadecimal point.
560Zeroes are always represented with a mantissa of 0 (preceded by a
561.Ql -
562if appropriate) and an exponent of
563.Li +0 .
564.It Cm C
565Treated as
566.Cm c
567with the
568.Cm l
569(ell) modifier.
570.It Cm c
571The
572.Vt int
573argument is converted to an
574.Vt "unsigned char" ,
575and the resulting character is written.
576.Pp
577If the
578.Cm l
579(ell) modifier is used, the
580.Vt wint_t
581argument shall be converted to a
582.Vt wchar_t ,
583and the (potentially multi-byte) sequence representing the
584single wide character is written, including any shift sequences.
585If a shift sequence is used, the shift state is also restored
586to the original state after the character.
587.It Cm S
588Treated as
589.Cm s
590with the
591.Cm l
592(ell) modifier.
593.It Cm s
594The
595.Vt "char *"
596argument is expected to be a pointer to an array of character type (pointer
597to a string).
598Characters from the array are written up to (but not including)
599a terminating
600.Dv NUL
601character;
602if a precision is specified, no more than the number specified are
603written.
604If a precision is given, no null character
605need be present; if the precision is not specified, or is greater than
606the size of the array, the array must contain a terminating
607.Dv NUL
608character.
609.Pp
610If the
611.Cm l
612(ell) modifier is used, the
613.Vt "wchar_t *"
614argument is expected to be a pointer to an array of wide characters
615(pointer to a wide string).
616For each wide character in the string, the (potentially multi-byte)
617sequence representing the
618wide character is written, including any shift sequences.
619If any shift sequence is used, the shift state is also restored
620to the original state after the string.
621Wide characters from the array are written up to (but not including)
622a terminating wide
623.Dv NUL
624character;
625if a precision is specified, no more than the number of bytes specified are
626written (including shift sequences).
627Partial characters are never written.
628If a precision is given, no null character
629need be present; if the precision is not specified, or is greater than
630the number of bytes required to render the multibyte representation of
631the string, the array must contain a terminating wide
632.Dv NUL
633character.
634.It Cm p
635The
636.Vt "void *"
637pointer argument is printed in hexadecimal (as if by
638.Ql %#x
639or
640.Ql %#lx ) .
641.It Cm n
642The number of characters written so far is stored into the
643integer indicated by the
644.Vt "int *"
645(or variant) pointer argument.
646No argument is converted.
647.It Cm %
648A
649.Ql %
650is written.
651No argument is converted.
652The complete conversion specification
653is
654.Ql %% .
655.El
656.Pp
657The decimal point
658character is defined in the program's locale (category
659.Dv LC_NUMERIC ) .
660.Pp
661In no case does a non-existent or small field width cause truncation of
662a numeric field; if the result of a conversion is wider than the field
663width, the
664field is expanded to contain the conversion result.
665.Sh EXAMPLES
666To print a date and time in the form
667.Dq Li "Sunday, July 3, 10:02" ,
668where
669.Fa weekday
670and
671.Fa month
672are pointers to strings:
673.Bd -literal -offset indent
674#include <stdio.h>
675fprintf(stdout, "%s, %s %d, %.2d:%.2d\en",
676	weekday, month, day, hour, min);
677.Ed
678.Pp
679To print \*(Pi
680to five decimal places:
681.Bd -literal -offset indent
682#include <math.h>
683#include <stdio.h>
684fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0));
685.Ed
686.Pp
687To allocate a 128 byte string and print into it:
688.Bd -literal -offset indent
689#include <stdio.h>
690#include <stdlib.h>
691#include <stdarg.h>
692char *newfmt(const char *fmt, ...)
693{
694	char *p;
695	va_list ap;
696	if ((p = malloc(128)) == NULL)
697		return (NULL);
698	va_start(ap, fmt);
699	(void) vsnprintf(p, 128, fmt, ap);
700	va_end(ap);
701	return (p);
702}
703.Ed
704.Sh SECURITY CONSIDERATIONS
705The
706.Fn sprintf
707and
708.Fn vsprintf
709functions are easily misused in a manner which enables malicious users
710to arbitrarily change a running program's functionality through
711a buffer overflow attack.
712Because
713.Fn sprintf
714and
715.Fn vsprintf
716assume an infinitely long string,
717callers must be careful not to overflow the actual space;
718this is often hard to assure.
719For safety, programmers should use the
720.Fn snprintf
721interface instead.
722For example:
723.Bd -literal
724void
725foo(const char *arbitrary_string, const char *and_another)
726{
727	char onstack[8];
728
729#ifdef BAD
730	/*
731	 * This first sprintf is bad behavior.  Do not use sprintf!
732	 */
733	sprintf(onstack, "%s, %s", arbitrary_string, and_another);
734#else
735	/*
736	 * The following two lines demonstrate better use of
737	 * snprintf().
738	 */
739	snprintf(onstack, sizeof(onstack), "%s, %s", arbitrary_string,
740	    and_another);
741#endif
742}
743.Ed
744.Pp
745The
746.Fn printf
747and
748.Fn sprintf
749family of functions are also easily misused in a manner
750allowing malicious users to arbitrarily change a running program's
751functionality by either causing the program
752to print potentially sensitive data
753.Dq "left on the stack" ,
754or causing it to generate a memory fault or bus error
755by dereferencing an invalid pointer.
756.Pp
757.Cm %n
758can be used to write arbitrary data to potentially carefully-selected
759addresses.
760Programmers are therefore strongly advised to never pass untrusted strings
761as the
762.Fa format
763argument, as an attacker can put format specifiers in the string
764to mangle your stack,
765leading to a possible security hole.
766This holds true even if the string was built using a function like
767.Fn snprintf ,
768as the resulting string may still contain user-supplied conversion specifiers
769for later interpolation by
770.Fn printf .
771.Pp
772Always use the proper secure idiom:
773.Pp
774.Dl "snprintf(buffer, sizeof(buffer), \*q%s\*q, string);"
775.Sh ERRORS
776In addition to the errors documented for the
777.Xr write 2
778system call, the
779.Fn printf
780family of functions may fail if:
781.Bl -tag -width Er
782.It Bq Er EILSEQ
783An invalid wide character code was encountered.
784.It Bq Er ENOMEM
785Insufficient storage space is available.
786.El
787.Sh SEE ALSO
788.Xr printf 1 ,
789.Xr fmtcheck 3 ,
790.Xr scanf 3 ,
791.Xr setlocale 3 ,
792.Xr wprintf 3
793.Sh STANDARDS
794Subject to the caveats noted in the
795.Sx BUGS
796section below, the
797.Fn fprintf ,
798.Fn printf ,
799.Fn sprintf ,
800.Fn vprintf ,
801.Fn vfprintf ,
802and
803.Fn vsprintf
804functions
805conform to
806.St -ansiC
807and
808.St -isoC-99 .
809With the same reservation, the
810.Fn snprintf
811and
812.Fn vsnprintf
813functions conform to
814.St -isoC-99 .
815.Sh HISTORY
816The functions
817.Fn asprintf
818and
819.Fn vasprintf
820first appeared in the
821.Tn GNU C
822library.
823These were implemented by
824.An Peter Wemm Aq peter@FreeBSD.org
825in
826.Fx 2.2 ,
827but were later replaced with a different implementation
828from
829.An Todd C. Miller Aq Todd.Miller@courtesan.com
830for
831.Ox 2.3 .
832.Sh BUGS
833The conversion formats
834.Cm \&%D , \&%O ,
835and
836.Cm %U
837are not standard and
838are provided only for backward compatibility.
839The effect of padding the
840.Cm %p
841format with zeros (either by the
842.Cm 0
843flag or by specifying a precision), and the benign effect (i.e., none)
844of the
845.Cm #
846flag on
847.Cm %n
848and
849.Cm %p
850conversions, as well as other
851nonsensical combinations such as
852.Cm %Ld ,
853are not standard; such combinations
854should be avoided.
855.Pp
856The
857.Nm
858family of functions do not correctly handle multibyte characters in the
859.Fa format
860argument.
861