xref: /freebsd/lib/libc/stdio/printf.3 (revision b3aaa0cc21c63d388230c7ef2a80abd631ff20d5)
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.
211For
212.Cm x
213and
214.Cm X
215conversions, a non-zero result has the string
216.Ql 0x
217(or
218.Ql 0X
219for
220.Cm X
221conversions) prepended to it.
222For
223.Cm a , A , e , E , f , F , g ,
224and
225.Cm G
226conversions, the result will always contain a decimal point, even if no
227digits follow it (normally, a decimal point appears in the results of
228those conversions only if a digit follows).
229For
230.Cm g
231and
232.Cm G
233conversions, trailing zeros are not removed from the result as they
234would otherwise be.
235.It So Cm 0 Sc (zero)
236Zero padding.
237For all conversions except
238.Cm n ,
239the converted value is padded on the left with zeros rather than blanks.
240If a precision is given with a numeric conversion
241.Cm ( d , i , o , u , i , x ,
242and
243.Cm X ) ,
244the
245.Cm 0
246flag is ignored.
247.It Sq Cm \-
248A negative field width flag;
249the converted value is to be left adjusted on the field boundary.
250Except for
251.Cm n
252conversions, the converted value is padded on the right with blanks,
253rather than on the left with blanks or zeros.
254A
255.Cm \-
256overrides a
257.Cm 0
258if both are given.
259.It So "\ " Sc (space)
260A blank should be left before a positive number
261produced by a signed conversion
262.Cm ( a , A , d , e , E , f , F , g , G ,
263or
264.Cm i ) .
265.It Sq Cm +
266A sign must always be placed before a
267number produced by a signed conversion.
268A
269.Cm +
270overrides a space if both are used.
271.It Sq Cm '
272Decimal conversions
273.Cm ( d , u ,
274or
275.Cm i )
276or the integral portion of a floating point conversion
277.Cm ( f
278or
279.Cm F )
280should be grouped and separated by thousands using
281the non-monetary separator returned by
282.Xr localeconv 3 .
283.El
284.It
285An optional decimal digit string specifying a minimum field width.
286If the converted value has fewer characters than the field width, it will
287be padded with spaces on the left (or right, if the left-adjustment
288flag has been given) to fill out
289the field width.
290.It
291An optional precision, in the form of a period
292.Cm \&.
293followed by an
294optional digit string.
295If the digit string is omitted, the precision is taken as zero.
296This gives the minimum number of digits to appear for
297.Cm d , i , o , u , x ,
298and
299.Cm X
300conversions, the number of digits to appear after the decimal-point for
301.Cm a , A , e , E , f ,
302and
303.Cm F
304conversions, the maximum number of significant digits for
305.Cm g
306and
307.Cm G
308conversions, or the maximum number of characters to be printed from a
309string for
310.Cm s
311conversions.
312.It
313An optional length modifier, that specifies the size of the argument.
314The following length modifiers are valid for the
315.Cm d , i , n , o , u , x ,
316or
317.Cm X
318conversion:
319.Bl -column ".Cm q Em (deprecated)" ".Vt signed char" ".Vt unsigned long long" ".Vt long long *"
320.It Sy Modifier Ta Cm d , i Ta Cm o , u , x , X Ta Cm n
321.It Cm hh Ta Vt "signed char" Ta Vt "unsigned char" Ta Vt "signed char *"
322.It Cm h Ta Vt short Ta Vt "unsigned short" Ta Vt "short *"
323.It Cm l No (ell) Ta Vt long Ta Vt "unsigned long" Ta Vt "long *"
324.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *"
325.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
326.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
327.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
328.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
329.El
330.Pp
331Note:
332the
333.Cm t
334modifier, when applied to a
335.Cm o , u , x ,
336or
337.Cm X
338conversion, indicates that the argument is of an unsigned type
339equivalent in size to a
340.Vt ptrdiff_t .
341The
342.Cm z
343modifier, when applied to a
344.Cm d
345or
346.Cm i
347conversion, indicates that the argument is of a signed type equivalent in
348size to a
349.Vt size_t .
350Similarly, when applied to an
351.Cm n
352conversion, it indicates that the argument is a pointer to a signed type
353equivalent in size to a
354.Vt size_t .
355.Pp
356The following length modifier is valid for the
357.Cm a , A , e , E , f , F , g ,
358or
359.Cm G
360conversion:
361.Bl -column ".Sy Modifier" ".Cm a , A , e , E , f , F , g , G"
362.It Sy Modifier Ta Cm a , A , e , E , f , F , g , G
363.It Cm l No (ell) Ta Vt double
364(ignored, same behavior as without it)
365.It Cm L Ta Vt "long double"
366.El
367.Pp
368The following length modifier is valid for the
369.Cm c
370or
371.Cm s
372conversion:
373.Bl -column ".Sy Modifier" ".Vt wint_t" ".Vt wchar_t *"
374.It Sy Modifier Ta Cm c Ta Cm s
375.It Cm l No (ell) Ta Vt wint_t Ta Vt "wchar_t *"
376.El
377.It
378A character that specifies the type of conversion to be applied.
379.El
380.Pp
381A field width or precision, or both, may be indicated by
382an asterisk
383.Ql *
384or an asterisk followed by one or more decimal digits and a
385.Ql $
386instead of a
387digit string.
388In this case, an
389.Vt int
390argument supplies the field width or precision.
391A negative field width is treated as a left adjustment flag followed by a
392positive field width; a negative precision is treated as though it were
393missing.
394If a single format directive mixes positional
395.Pq Li nn$
396and non-positional arguments, the results are undefined.
397.Pp
398The conversion specifiers and their meanings are:
399.Bl -tag -width ".Cm diouxX"
400.It Cm diouxX
401The
402.Vt int
403(or appropriate variant) argument is converted to signed decimal
404.Cm ( d
405and
406.Cm i ) ,
407unsigned octal
408.Pq Cm o ,
409unsigned decimal
410.Pq Cm u ,
411or unsigned hexadecimal
412.Cm ( x
413and
414.Cm X )
415notation.
416The letters
417.Dq Li abcdef
418are used for
419.Cm x
420conversions; the letters
421.Dq Li ABCDEF
422are used for
423.Cm X
424conversions.
425The precision, if any, gives the minimum number of digits that must
426appear; if the converted value requires fewer digits, it is padded on
427the left with zeros.
428.It Cm DOU
429The
430.Vt "long int"
431argument is converted to signed decimal, unsigned octal, or unsigned
432decimal, as if the format had been
433.Cm ld , lo ,
434or
435.Cm lu
436respectively.
437These conversion characters are deprecated, and will eventually disappear.
438.It Cm eE
439The
440.Vt double
441argument is rounded and converted in the style
442.Sm off
443.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd
444.Sm on
445where there is one digit before the
446decimal-point character
447and the number of digits after it is equal to the precision;
448if the precision is missing,
449it is taken as 6; if the precision is
450zero, no decimal-point character appears.
451An
452.Cm E
453conversion uses the letter
454.Ql E
455(rather than
456.Ql e )
457to introduce the exponent.
458The exponent always contains at least two digits; if the value is zero,
459the exponent is 00.
460.Pp
461For
462.Cm a , A , e , E , f , F , g ,
463and
464.Cm G
465conversions, positive and negative infinity are represented as
466.Li inf
467and
468.Li -inf
469respectively when using the lowercase conversion character, and
470.Li INF
471and
472.Li -INF
473respectively when using the uppercase conversion character.
474Similarly, NaN is represented as
475.Li nan
476when using the lowercase conversion, and
477.Li NAN
478when using the uppercase conversion.
479.It Cm fF
480The
481.Vt double
482argument is rounded and converted to decimal notation in the style
483.Sm off
484.Oo \- Oc Ar ddd Li \&. Ar ddd ,
485.Sm on
486where the number of digits after the decimal-point character
487is equal to the precision specification.
488If the precision is missing, it is taken as 6; if the precision is
489explicitly zero, no decimal-point character appears.
490If a decimal point appears, at least one digit appears before it.
491.It Cm gG
492The
493.Vt double
494argument is converted in style
495.Cm f
496or
497.Cm e
498(or
499.Cm F
500or
501.Cm E
502for
503.Cm G
504conversions).
505The precision specifies the number of significant digits.
506If the precision is missing, 6 digits are given; if the precision is zero,
507it is treated as 1.
508Style
509.Cm e
510is used if the exponent from its conversion is less than \-4 or greater than
511or equal to the precision.
512Trailing zeros are removed from the fractional part of the result; a
513decimal point appears only if it is followed by at least one digit.
514.It Cm aA
515The
516.Vt double
517argument is rounded and converted to hexadecimal notation in the style
518.Sm off
519.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d ,
520.Sm on
521where the number of digits after the hexadecimal-point character
522is equal to the precision specification.
523If the precision is missing, it is taken as enough to represent
524the floating-point number exactly, and no rounding occurs.
525If the precision is zero, no hexadecimal-point character appears.
526The
527.Cm p
528is a literal character
529.Ql p ,
530and the exponent consists of a positive or negative sign
531followed by a decimal number representing an exponent of 2.
532The
533.Cm A
534conversion uses the prefix
535.Dq Li 0X
536(rather than
537.Dq Li 0x ) ,
538the letters
539.Dq Li ABCDEF
540(rather than
541.Dq Li abcdef )
542to represent the hex digits, and the letter
543.Ql P
544(rather than
545.Ql p )
546to separate the mantissa and exponent.
547.Pp
548Note that there may be multiple valid ways to represent floating-point
549numbers in this hexadecimal format.
550For example,
551.Li 0x1.92p+1 , 0x3.24p+0 , 0x6.48p-1 ,
552and
553.Li 0xc.9p-2
554are all equivalent.
555.Fx 8.0
556and later always prints finite non-zero numbers using
557.Ql 1
558as the digit before the hexadecimal point.
559Zeroes are always represented with a mantissa of 0 (preceded by a
560.Ql -
561if appropriate) and an exponent of
562.Li +0 .
563.It Cm C
564Treated as
565.Cm c
566with the
567.Cm l
568(ell) modifier.
569.It Cm c
570The
571.Vt int
572argument is converted to an
573.Vt "unsigned char" ,
574and the resulting character is written.
575.Pp
576If the
577.Cm l
578(ell) modifier is used, the
579.Vt wint_t
580argument shall be converted to a
581.Vt wchar_t ,
582and the (potentially multi-byte) sequence representing the
583single wide character is written, including any shift sequences.
584If a shift sequence is used, the shift state is also restored
585to the original state after the character.
586.It Cm S
587Treated as
588.Cm s
589with the
590.Cm l
591(ell) modifier.
592.It Cm s
593The
594.Vt "char *"
595argument is expected to be a pointer to an array of character type (pointer
596to a string).
597Characters from the array are written up to (but not including)
598a terminating
599.Dv NUL
600character;
601if a precision is specified, no more than the number specified are
602written.
603If a precision is given, no null character
604need be present; if the precision is not specified, or is greater than
605the size of the array, the array must contain a terminating
606.Dv NUL
607character.
608.Pp
609If the
610.Cm l
611(ell) modifier is used, the
612.Vt "wchar_t *"
613argument is expected to be a pointer to an array of wide characters
614(pointer to a wide string).
615For each wide character in the string, the (potentially multi-byte)
616sequence representing the
617wide character is written, including any shift sequences.
618If any shift sequence is used, the shift state is also restored
619to the original state after the string.
620Wide characters from the array are written up to (but not including)
621a terminating wide
622.Dv NUL
623character;
624if a precision is specified, no more than the number of bytes specified are
625written (including shift sequences).
626Partial characters are never written.
627If a precision is given, no null character
628need be present; if the precision is not specified, or is greater than
629the number of bytes required to render the multibyte representation of
630the string, the array must contain a terminating wide
631.Dv NUL
632character.
633.It Cm p
634The
635.Vt "void *"
636pointer argument is printed in hexadecimal (as if by
637.Ql %#x
638or
639.Ql %#lx ) .
640.It Cm n
641The number of characters written so far is stored into the
642integer indicated by the
643.Vt "int *"
644(or variant) pointer argument.
645No argument is converted.
646.It Cm %
647A
648.Ql %
649is written.
650No argument is converted.
651The complete conversion specification
652is
653.Ql %% .
654.El
655.Pp
656The decimal point
657character is defined in the program's locale (category
658.Dv LC_NUMERIC ) .
659.Pp
660In no case does a non-existent or small field width cause truncation of
661a numeric field; if the result of a conversion is wider than the field
662width, the
663field is expanded to contain the conversion result.
664.Sh EXAMPLES
665To print a date and time in the form
666.Dq Li "Sunday, July 3, 10:02" ,
667where
668.Fa weekday
669and
670.Fa month
671are pointers to strings:
672.Bd -literal -offset indent
673#include <stdio.h>
674fprintf(stdout, "%s, %s %d, %.2d:%.2d\en",
675	weekday, month, day, hour, min);
676.Ed
677.Pp
678To print \*(Pi
679to five decimal places:
680.Bd -literal -offset indent
681#include <math.h>
682#include <stdio.h>
683fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0));
684.Ed
685.Pp
686To allocate a 128 byte string and print into it:
687.Bd -literal -offset indent
688#include <stdio.h>
689#include <stdlib.h>
690#include <stdarg.h>
691char *newfmt(const char *fmt, ...)
692{
693	char *p;
694	va_list ap;
695	if ((p = malloc(128)) == NULL)
696		return (NULL);
697	va_start(ap, fmt);
698	(void) vsnprintf(p, 128, fmt, ap);
699	va_end(ap);
700	return (p);
701}
702.Ed
703.Sh SECURITY CONSIDERATIONS
704The
705.Fn sprintf
706and
707.Fn vsprintf
708functions are easily misused in a manner which enables malicious users
709to arbitrarily change a running program's functionality through
710a buffer overflow attack.
711Because
712.Fn sprintf
713and
714.Fn vsprintf
715assume an infinitely long string,
716callers must be careful not to overflow the actual space;
717this is often hard to assure.
718For safety, programmers should use the
719.Fn snprintf
720interface instead.
721For example:
722.Bd -literal
723void
724foo(const char *arbitrary_string, const char *and_another)
725{
726	char onstack[8];
727
728#ifdef BAD
729	/*
730	 * This first sprintf is bad behavior.  Do not use sprintf!
731	 */
732	sprintf(onstack, "%s, %s", arbitrary_string, and_another);
733#else
734	/*
735	 * The following two lines demonstrate better use of
736	 * snprintf().
737	 */
738	snprintf(onstack, sizeof(onstack), "%s, %s", arbitrary_string,
739	    and_another);
740#endif
741}
742.Ed
743.Pp
744The
745.Fn printf
746and
747.Fn sprintf
748family of functions are also easily misused in a manner
749allowing malicious users to arbitrarily change a running program's
750functionality by either causing the program
751to print potentially sensitive data
752.Dq "left on the stack" ,
753or causing it to generate a memory fault or bus error
754by dereferencing an invalid pointer.
755.Pp
756.Cm %n
757can be used to write arbitrary data to potentially carefully-selected
758addresses.
759Programmers are therefore strongly advised to never pass untrusted strings
760as the
761.Fa format
762argument, as an attacker can put format specifiers in the string
763to mangle your stack,
764leading to a possible security hole.
765This holds true even if the string was built using a function like
766.Fn snprintf ,
767as the resulting string may still contain user-supplied conversion specifiers
768for later interpolation by
769.Fn printf .
770.Pp
771Always use the proper secure idiom:
772.Pp
773.Dl "snprintf(buffer, sizeof(buffer), \*q%s\*q, string);"
774.Sh ERRORS
775In addition to the errors documented for the
776.Xr write 2
777system call, the
778.Fn printf
779family of functions may fail if:
780.Bl -tag -width Er
781.It Bq Er EILSEQ
782An invalid wide character code was encountered.
783.It Bq Er ENOMEM
784Insufficient storage space is available.
785.El
786.Sh SEE ALSO
787.Xr printf 1 ,
788.Xr fmtcheck 3 ,
789.Xr scanf 3 ,
790.Xr setlocale 3 ,
791.Xr wprintf 3
792.Sh STANDARDS
793Subject to the caveats noted in the
794.Sx BUGS
795section below, the
796.Fn fprintf ,
797.Fn printf ,
798.Fn sprintf ,
799.Fn vprintf ,
800.Fn vfprintf ,
801and
802.Fn vsprintf
803functions
804conform to
805.St -ansiC
806and
807.St -isoC-99 .
808With the same reservation, the
809.Fn snprintf
810and
811.Fn vsnprintf
812functions conform to
813.St -isoC-99 .
814.Sh HISTORY
815The functions
816.Fn asprintf
817and
818.Fn vasprintf
819first appeared in the
820.Tn GNU C
821library.
822These were implemented by
823.An Peter Wemm Aq peter@FreeBSD.org
824in
825.Fx 2.2 ,
826but were later replaced with a different implementation
827from
828.An Todd C. Miller Aq Todd.Miller@courtesan.com
829for
830.Ox 2.3 .
831.Sh BUGS
832The conversion formats
833.Cm \&%D , \&%O ,
834and
835.Cm %U
836are not standard and
837are provided only for backward compatibility.
838The effect of padding the
839.Cm %p
840format with zeros (either by the
841.Cm 0
842flag or by specifying a precision), and the benign effect (i.e., none)
843of the
844.Cm #
845flag on
846.Cm %n
847and
848.Cm %p
849conversions, as well as other
850nonsensical combinations such as
851.Cm %Ld ,
852are not standard; such combinations
853should be avoided.
854.Pp
855The
856.Nm
857family of functions do not correctly handle multibyte characters in the
858.Fa format
859argument.
860