1c5604d0aSTim J. Robbins.\" Copyright (c) 1990, 1991, 1993 2c5604d0aSTim J. Robbins.\" The Regents of the University of California. All rights reserved. 3c5604d0aSTim J. Robbins.\" 4c5604d0aSTim J. Robbins.\" This code is derived from software contributed to Berkeley by 5c5604d0aSTim J. Robbins.\" Chris Torek and the American National Standards Committee X3, 6c5604d0aSTim J. Robbins.\" on Information Processing Systems. 7c5604d0aSTim J. Robbins.\" 8c5604d0aSTim J. Robbins.\" Redistribution and use in source and binary forms, with or without 9c5604d0aSTim J. Robbins.\" modification, are permitted provided that the following conditions 10c5604d0aSTim J. Robbins.\" are met: 11c5604d0aSTim J. Robbins.\" 1. Redistributions of source code must retain the above copyright 12c5604d0aSTim J. Robbins.\" notice, this list of conditions and the following disclaimer. 13c5604d0aSTim J. Robbins.\" 2. Redistributions in binary form must reproduce the above copyright 14c5604d0aSTim J. Robbins.\" notice, this list of conditions and the following disclaimer in the 15c5604d0aSTim J. Robbins.\" documentation and/or other materials provided with the distribution. 16c5604d0aSTim J. Robbins.\" 3. All advertising materials mentioning features or use of this software 17c5604d0aSTim J. Robbins.\" must display the following acknowledgement: 18c5604d0aSTim J. Robbins.\" This product includes software developed by the University of 19c5604d0aSTim J. Robbins.\" California, Berkeley and its contributors. 20c5604d0aSTim J. Robbins.\" 4. Neither the name of the University nor the names of its contributors 21c5604d0aSTim J. Robbins.\" may be used to endorse or promote products derived from this software 22c5604d0aSTim J. Robbins.\" without specific prior written permission. 23c5604d0aSTim J. Robbins.\" 24c5604d0aSTim J. Robbins.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25c5604d0aSTim J. Robbins.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26c5604d0aSTim J. Robbins.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27c5604d0aSTim J. Robbins.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28c5604d0aSTim J. Robbins.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29c5604d0aSTim J. Robbins.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30c5604d0aSTim J. Robbins.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31c5604d0aSTim J. Robbins.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32c5604d0aSTim J. Robbins.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33c5604d0aSTim J. Robbins.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34c5604d0aSTim J. Robbins.\" SUCH DAMAGE. 35c5604d0aSTim J. Robbins.\" 36c5604d0aSTim J. Robbins.\" @(#)printf.3 8.1 (Berkeley) 6/4/93 37c5604d0aSTim J. Robbins.\" FreeBSD: src/lib/libc/stdio/printf.3,v 1.47 2002/09/06 11:23:55 tjr Exp 38c5604d0aSTim J. Robbins.\" $FreeBSD$ 39c5604d0aSTim J. Robbins.\" 40c5604d0aSTim J. Robbins.Dd September 18, 2002 41c5604d0aSTim J. Robbins.Dt WPRINTF 3 42c5604d0aSTim J. Robbins.Os 43c5604d0aSTim J. Robbins.Sh NAME 44c5604d0aSTim J. Robbins.Nm wprintf , fwprintf , swprintf , 45c5604d0aSTim J. Robbins.Nm vwprintf , vfwprintf , vswprintf 46c5604d0aSTim J. Robbins.Nd formatted wide character output conversion 47c5604d0aSTim J. Robbins.Sh LIBRARY 48c5604d0aSTim J. Robbins.Lb libc 49c5604d0aSTim J. Robbins.Sh SYNOPSIS 50c5604d0aSTim J. Robbins.In stdio.h 51c5604d0aSTim J. Robbins.In wchar.h 52c5604d0aSTim J. Robbins.Ft int 53c5604d0aSTim J. Robbins.Fn fwprintf "FILE * restrict stream" "const wchar_t * restrict format" ... 54c5604d0aSTim J. Robbins.Ft int 55c5604d0aSTim J. Robbins.Fn swprintf "wchar_t * restrict ws" "size_t n" "const wchar_t * restrict format" ... 56c5604d0aSTim J. Robbins.Ft int 57c5604d0aSTim J. Robbins.Fn wprintf "const wchar_t * restrict format" ... 58c5604d0aSTim J. Robbins.In stdarg.h 59c5604d0aSTim J. Robbins.Ft int 60c5604d0aSTim J. Robbins.Fn vfwprintf "FILE * restrict stream" "const wchar_t * restrict" "va_list ap" 61c5604d0aSTim J. Robbins.Ft int 62c5604d0aSTim J. Robbins.Fn vswprintf "wchar_t * restrict ws" "size_t n" "const wchar_t *restrict format" "va_list ap" 63c5604d0aSTim J. Robbins.Ft int 64c5604d0aSTim J. Robbins.Fn vwprintf "const wchar_t * restrict format" "va_list ap" 65c5604d0aSTim J. Robbins.Sh DESCRIPTION 66c5604d0aSTim J. RobbinsThe 67c5604d0aSTim J. Robbins.Fn wprintf 68c5604d0aSTim J. Robbinsfamily of functions produces output according to a 69c5604d0aSTim J. Robbins.Fa format 70c5604d0aSTim J. Robbinsas described below. 71c5604d0aSTim J. RobbinsThe 72c5604d0aSTim J. Robbins.Fn wprintf 73c5604d0aSTim J. Robbinsand 74c5604d0aSTim J. Robbins.Fn vwprintf 75c5604d0aSTim J. Robbinsfunctions 76c5604d0aSTim J. Robbinswrite output to 77c5604d0aSTim J. Robbins.Pa stdout , 78c5604d0aSTim J. Robbinsthe standard output stream; 79c5604d0aSTim J. Robbins.Fn fwprintf 80c5604d0aSTim J. Robbinsand 81c5604d0aSTim J. Robbins.Fn vfwprintf 82c5604d0aSTim J. Robbinswrite output to the given output 83c5604d0aSTim J. Robbins.Fa stream ; 840e2e1007STim J. Robbins.Fn swprintf 85c5604d0aSTim J. Robbinsand 860e2e1007STim J. Robbins.Fn vswprintf 87c5604d0aSTim J. Robbinswrite to the wide character string 88c5604d0aSTim J. Robbins.Fa ws . 89c5604d0aSTim J. Robbins.Pp 90c5604d0aSTim J. RobbinsThese functions write the output under the control of a 91c5604d0aSTim J. Robbins.Fa format 92c5604d0aSTim J. Robbinsstring that specifies how subsequent arguments 93c5604d0aSTim J. Robbins(or arguments accessed via the variable-length argument facilities of 94c5604d0aSTim J. Robbins.Xr stdarg 3 ) 95c5604d0aSTim J. Robbinsare converted for output. 96c5604d0aSTim J. Robbins.Pp 97c5604d0aSTim J. RobbinsThese functions return the number of characters printed 98c5604d0aSTim J. Robbins(not including the trailing 99c5604d0aSTim J. Robbins.Ql \e0 100c5604d0aSTim J. Robbinsused to end output to strings). 101c5604d0aSTim J. Robbins.Pp 102c5604d0aSTim J. RobbinsThe 103c5604d0aSTim J. Robbins.Fn swprintf 104c5604d0aSTim J. Robbinsand 105c5604d0aSTim J. Robbins.Fn vswprintf 106c5604d0aSTim J. Robbinsfunctions will fail if 107c5604d0aSTim J. Robbins.Fa n 108c5604d0aSTim J. Robbinsor more wide characters were requested to be written, 109c5604d0aSTim J. Robbins.Pp 110c5604d0aSTim J. RobbinsThe format string is composed of zero or more directives: 111c5604d0aSTim J. Robbinsordinary 112c5604d0aSTim J. Robbinscharacters (not 113c5604d0aSTim J. Robbins.Cm % ) , 114c5604d0aSTim J. Robbinswhich are copied unchanged to the output stream; 115c5604d0aSTim J. Robbinsand conversion specifications, each of which results 116c5604d0aSTim J. Robbinsin fetching zero or more subsequent arguments. 117c5604d0aSTim J. RobbinsEach conversion specification is introduced by 118c5604d0aSTim J. Robbinsthe 119c5604d0aSTim J. Robbins.Cm % 120c5604d0aSTim J. Robbinscharacter. 121c5604d0aSTim J. RobbinsThe arguments must correspond properly (after type promotion) 122c5604d0aSTim J. Robbinswith the conversion specifier. 123c5604d0aSTim J. RobbinsAfter the 124c5604d0aSTim J. Robbins.Cm % , 125c5604d0aSTim J. Robbinsthe following appear in sequence: 126c5604d0aSTim J. Robbins.Bl -bullet 127c5604d0aSTim J. Robbins.It 128c5604d0aSTim J. RobbinsAn optional field, consisting of a decimal digit string followed by a 129c5604d0aSTim J. Robbins.Cm $ , 130c5604d0aSTim J. Robbinsspecifying the next argument to access. 131c5604d0aSTim J. RobbinsIf this field is not provided, the argument following the last 132c5604d0aSTim J. Robbinsargument accessed will be used. 133c5604d0aSTim J. RobbinsArguments are numbered starting at 134c5604d0aSTim J. Robbins.Cm 1 . 135c5604d0aSTim J. RobbinsIf unaccessed arguments in the format string are interspersed with ones that 136c5604d0aSTim J. Robbinsare accessed the results will be indeterminate. 137c5604d0aSTim J. Robbins.It 138c5604d0aSTim J. RobbinsZero or more of the following flags: 139c5604d0aSTim J. Robbins.Bl -tag -width ".So \ Sc (space)" 140c5604d0aSTim J. Robbins.It Sq Cm # 141c5604d0aSTim J. RobbinsThe value should be converted to an 142c5604d0aSTim J. Robbins.Dq alternate form . 143c5604d0aSTim J. RobbinsFor 144c5604d0aSTim J. Robbins.Cm c , d , i , n , p , s , 145c5604d0aSTim J. Robbinsand 146c5604d0aSTim J. Robbins.Cm u 147c5604d0aSTim J. Robbinsconversions, this option has no effect. 148c5604d0aSTim J. RobbinsFor 149c5604d0aSTim J. Robbins.Cm o 150c5604d0aSTim J. Robbinsconversions, the precision of the number is increased to force the first 151c5604d0aSTim J. Robbinscharacter of the output string to a zero (except if a zero value is printed 152c5604d0aSTim J. Robbinswith an explicit precision of zero). 153c5604d0aSTim J. RobbinsFor 154c5604d0aSTim J. Robbins.Cm x 155c5604d0aSTim J. Robbinsand 156c5604d0aSTim J. Robbins.Cm X 157c5604d0aSTim J. Robbinsconversions, a non-zero result has the string 158c5604d0aSTim J. Robbins.Ql 0x 159c5604d0aSTim J. Robbins(or 160c5604d0aSTim J. Robbins.Ql 0X 161c5604d0aSTim J. Robbinsfor 162c5604d0aSTim J. Robbins.Cm X 163c5604d0aSTim J. Robbinsconversions) prepended to it. 164c5604d0aSTim J. RobbinsFor 165c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g , 166c5604d0aSTim J. Robbinsand 167c5604d0aSTim J. Robbins.Cm G 168c5604d0aSTim J. Robbinsconversions, the result will always contain a decimal point, even if no 169c5604d0aSTim J. Robbinsdigits follow it (normally, a decimal point appears in the results of 170c5604d0aSTim J. Robbinsthose conversions only if a digit follows). 171c5604d0aSTim J. RobbinsFor 172c5604d0aSTim J. Robbins.Cm g 173c5604d0aSTim J. Robbinsand 174c5604d0aSTim J. Robbins.Cm G 175c5604d0aSTim J. Robbinsconversions, trailing zeros are not removed from the result as they 176c5604d0aSTim J. Robbinswould otherwise be. 177c5604d0aSTim J. Robbins.It So Cm 0 Sc (zero) 178c5604d0aSTim J. RobbinsZero padding. 179c5604d0aSTim J. RobbinsFor all conversions except 180c5604d0aSTim J. Robbins.Cm n , 181c5604d0aSTim J. Robbinsthe converted value is padded on the left with zeros rather than blanks. 182c5604d0aSTim J. RobbinsIf a precision is given with a numeric conversion 183c5604d0aSTim J. Robbins.Cm ( d , i , o , u , i , x , 184c5604d0aSTim J. Robbinsand 185c5604d0aSTim J. Robbins.Cm X ) , 186c5604d0aSTim J. Robbinsthe 187c5604d0aSTim J. Robbins.Cm 0 188c5604d0aSTim J. Robbinsflag is ignored. 189c5604d0aSTim J. Robbins.It Sq Cm \- 190c5604d0aSTim J. RobbinsA negative field width flag; 191c5604d0aSTim J. Robbinsthe converted value is to be left adjusted on the field boundary. 192c5604d0aSTim J. RobbinsExcept for 193c5604d0aSTim J. Robbins.Cm n 194c5604d0aSTim J. Robbinsconversions, the converted value is padded on the right with blanks, 195c5604d0aSTim J. Robbinsrather than on the left with blanks or zeros. 196c5604d0aSTim J. RobbinsA 197c5604d0aSTim J. Robbins.Cm \- 198c5604d0aSTim J. Robbinsoverrides a 199c5604d0aSTim J. Robbins.Cm 0 200c5604d0aSTim J. Robbinsif both are given. 201c5604d0aSTim J. Robbins.It So "\ " Sc (space) 202c5604d0aSTim J. RobbinsA blank should be left before a positive number 203c5604d0aSTim J. Robbinsproduced by a signed conversion 204c5604d0aSTim J. Robbins.Cm ( a , A , d , e , E , f , F , g , G , 205c5604d0aSTim J. Robbinsor 206c5604d0aSTim J. Robbins.Cm i ) . 207c5604d0aSTim J. Robbins.It Sq Cm + 208c5604d0aSTim J. RobbinsA sign must always be placed before a 209c5604d0aSTim J. Robbinsnumber produced by a signed conversion. 210c5604d0aSTim J. RobbinsA 211c5604d0aSTim J. Robbins.Cm + 212c5604d0aSTim J. Robbinsoverrides a space if both are used. 213c5604d0aSTim J. Robbins.It Sq Cm ' 214c5604d0aSTim J. RobbinsDecimal conversions 215c5604d0aSTim J. Robbins.Cm ( d , u , 216c5604d0aSTim J. Robbinsor 217c5604d0aSTim J. Robbins.Cm i ) 218c5604d0aSTim J. Robbinsor the integral portion of a floating point conversion 219c5604d0aSTim J. Robbins.Cm ( f 220c5604d0aSTim J. Robbinsor 221c5604d0aSTim J. Robbins.Cm F ) 222c5604d0aSTim J. Robbinsshould be grouped and separated by thousands using 223c5604d0aSTim J. Robbinsthe non-monetary separator returned by 224c5604d0aSTim J. Robbins.Xr localeconv 3 . 225c5604d0aSTim J. Robbins.El 226c5604d0aSTim J. Robbins.It 227c5604d0aSTim J. RobbinsAn optional decimal digit string specifying a minimum field width. 228c5604d0aSTim J. RobbinsIf the converted value has fewer characters than the field width, it will 229c5604d0aSTim J. Robbinsbe padded with spaces on the left (or right, if the left-adjustment 230c5604d0aSTim J. Robbinsflag has been given) to fill out 231c5604d0aSTim J. Robbinsthe field width. 232c5604d0aSTim J. Robbins.It 233c5604d0aSTim J. RobbinsAn optional precision, in the form of a period 234c5604d0aSTim J. Robbins.Cm \&. 235c5604d0aSTim J. Robbinsfollowed by an 236c5604d0aSTim J. Robbinsoptional digit string. 237c5604d0aSTim J. RobbinsIf the digit string is omitted, the precision is taken as zero. 238c5604d0aSTim J. RobbinsThis gives the minimum number of digits to appear for 239c5604d0aSTim J. Robbins.Cm d , i , o , u , x , 240c5604d0aSTim J. Robbinsand 241c5604d0aSTim J. Robbins.Cm X 242c5604d0aSTim J. Robbinsconversions, the number of digits to appear after the decimal-point for 243c5604d0aSTim J. Robbins.Cm a , A , e , E , f , 244c5604d0aSTim J. Robbinsand 245c5604d0aSTim J. Robbins.Cm F 246c5604d0aSTim J. Robbinsconversions, the maximum number of significant digits for 247c5604d0aSTim J. Robbins.Cm g 248c5604d0aSTim J. Robbinsand 249c5604d0aSTim J. Robbins.Cm G 250c5604d0aSTim J. Robbinsconversions, or the maximum number of characters to be printed from a 251c5604d0aSTim J. Robbinsstring for 252c5604d0aSTim J. Robbins.Cm s 253c5604d0aSTim J. Robbinsconversions. 254c5604d0aSTim J. Robbins.It 255c5604d0aSTim J. RobbinsAn optional length modifier, that specifies the size of the argument. 256c5604d0aSTim J. RobbinsThe following length modifiers are valid for the 257c5604d0aSTim J. Robbins.Cm d , i , n , o , u , x , 258c5604d0aSTim J. Robbinsor 259c5604d0aSTim J. Robbins.Cm X 260c5604d0aSTim J. Robbinsconversion: 261c5604d0aSTim J. Robbins.Bl -column ".Cm q Em (deprecated)" ".Vt signed char" ".Vt unsigned long long" ".Vt long long *" 262c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm d , i Ta Cm o , u , x , X Ta Cm n 263c5604d0aSTim J. Robbins.It Cm hh Ta Vt "signed char" Ta Vt "unsigned char" Ta Vt "signed char *" 264c5604d0aSTim J. Robbins.It Cm h Ta Vt short Ta Vt "unsigned short" Ta Vt "short *" 265c5604d0aSTim J. Robbins.It Cm l No (ell) Ta Vt long Ta Vt "unsigned long" Ta Vt "long *" 266c5604d0aSTim J. Robbins.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *" 267c5604d0aSTim J. Robbins.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *" 268c5604d0aSTim J. Robbins.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *" 269c5604d0aSTim J. Robbins.It Cm z Ta (see note) Ta Vt size_t Ta (see note) 270c5604d0aSTim J. Robbins.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *" 271c5604d0aSTim J. Robbins.El 272c5604d0aSTim J. Robbins.Pp 273c5604d0aSTim J. RobbinsNote: 274c5604d0aSTim J. Robbinsthe 275c5604d0aSTim J. Robbins.Cm t 276c5604d0aSTim J. Robbinsmodifier, when applied to a 277c5604d0aSTim J. Robbins.Cm o , u , x , 278c5604d0aSTim J. Robbinsor 279c5604d0aSTim J. Robbins.Cm X 280c5604d0aSTim J. Robbinsconversion, indicates that the argument is of an unsigned type 281c5604d0aSTim J. Robbinsequivalent in size to a 282c5604d0aSTim J. Robbins.Vt ptrdiff_t . 283c5604d0aSTim J. RobbinsThe 284c5604d0aSTim J. Robbins.Cm z 285c5604d0aSTim J. Robbinsmodifier, when applied to a 286c5604d0aSTim J. Robbins.Cm d 287c5604d0aSTim J. Robbinsor 288c5604d0aSTim J. Robbins.Cm i 289c5604d0aSTim J. Robbinsconversion, indicates that the argument is of a signed type equivalent in 290c5604d0aSTim J. Robbinssize to a 291c5604d0aSTim J. Robbins.Vt size_t . 292c5604d0aSTim J. RobbinsSimilarly, when applied to an 293c5604d0aSTim J. Robbins.Cm n 294c5604d0aSTim J. Robbinsconversion, it indicates that the argument is a pointer to a signed type 295c5604d0aSTim J. Robbinsequivalent in size to a 296c5604d0aSTim J. Robbins.Vt size_t . 297c5604d0aSTim J. Robbins.Pp 298c5604d0aSTim J. RobbinsThe following length modifier is valid for the 299c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g , 300c5604d0aSTim J. Robbinsor 301c5604d0aSTim J. Robbins.Cm G 302c5604d0aSTim J. Robbinsconversion: 303c5604d0aSTim J. Robbins.Bl -column ".Sy Modifier" ".Cm a , A , e , E , f , F , g , G" 304c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm a , A , e , E , f , F , g , G 305c5604d0aSTim J. Robbins.It Cm L Ta Vt "long double" 306c5604d0aSTim J. Robbins.El 307c5604d0aSTim J. Robbins.Pp 308c5604d0aSTim J. RobbinsThe following length modifier is valid for the 309c5604d0aSTim J. Robbins.Cm c 310c5604d0aSTim J. Robbinsor 311c5604d0aSTim J. Robbins.Cm s 312c5604d0aSTim J. Robbinsconversion: 313c5604d0aSTim J. Robbins.Bl -column ".Sy Modifier" ".Vt wint_t" ".Vt wchar_t *" 314c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm c Ta Cm s 315c5604d0aSTim J. Robbins.It Cm l No (ell) Ta Vt wint_t Ta Vt "wchar_t *" 316c5604d0aSTim J. Robbins.El 317c5604d0aSTim J. Robbins.It 318c5604d0aSTim J. RobbinsA character that specifies the type of conversion to be applied. 319c5604d0aSTim J. Robbins.El 320c5604d0aSTim J. Robbins.Pp 321c5604d0aSTim J. RobbinsA field width or precision, or both, may be indicated by 322c5604d0aSTim J. Robbinsan asterisk 323c5604d0aSTim J. Robbins.Ql * 324c5604d0aSTim J. Robbinsor an asterisk followed by one or more decimal digits and a 325c5604d0aSTim J. Robbins.Ql $ 326c5604d0aSTim J. Robbinsinstead of a 327c5604d0aSTim J. Robbinsdigit string. 328c5604d0aSTim J. RobbinsIn this case, an 329c5604d0aSTim J. Robbins.Vt int 330c5604d0aSTim J. Robbinsargument supplies the field width or precision. 331c5604d0aSTim J. RobbinsA negative field width is treated as a left adjustment flag followed by a 332c5604d0aSTim J. Robbinspositive field width; a negative precision is treated as though it were 333c5604d0aSTim J. Robbinsmissing. 334c5604d0aSTim J. RobbinsIf a single format directive mixes positional 335c5604d0aSTim J. Robbins.Pq Li nn$ 336c5604d0aSTim J. Robbinsand non-positional arguments, the results are undefined. 337c5604d0aSTim J. Robbins.Pp 338c5604d0aSTim J. RobbinsThe conversion specifiers and their meanings are: 339c5604d0aSTim J. Robbins.Bl -tag -width ".Cm diouxX" 340c5604d0aSTim J. Robbins.It Cm diouxX 341c5604d0aSTim J. RobbinsThe 342c5604d0aSTim J. Robbins.Vt int 343c5604d0aSTim J. Robbins(or appropriate variant) argument is converted to signed decimal 344c5604d0aSTim J. Robbins.Cm ( d 345c5604d0aSTim J. Robbinsand 346c5604d0aSTim J. Robbins.Cm i ) , 347c5604d0aSTim J. Robbinsunsigned octal 348c5604d0aSTim J. Robbins.Pq Cm o , 349c5604d0aSTim J. Robbinsunsigned decimal 350c5604d0aSTim J. Robbins.Pq Cm u , 351c5604d0aSTim J. Robbinsor unsigned hexadecimal 352c5604d0aSTim J. Robbins.Cm ( x 353c5604d0aSTim J. Robbinsand 354c5604d0aSTim J. Robbins.Cm X ) 355c5604d0aSTim J. Robbinsnotation. 356c5604d0aSTim J. RobbinsThe letters 357c5604d0aSTim J. Robbins.Dq Li abcdef 358c5604d0aSTim J. Robbinsare used for 359c5604d0aSTim J. Robbins.Cm x 360c5604d0aSTim J. Robbinsconversions; the letters 361c5604d0aSTim J. Robbins.Dq Li ABCDEF 362c5604d0aSTim J. Robbinsare used for 363c5604d0aSTim J. Robbins.Cm X 364c5604d0aSTim J. Robbinsconversions. 365c5604d0aSTim J. RobbinsThe precision, if any, gives the minimum number of digits that must 366c5604d0aSTim J. Robbinsappear; if the converted value requires fewer digits, it is padded on 367c5604d0aSTim J. Robbinsthe left with zeros. 368c5604d0aSTim J. Robbins.It Cm DOU 369c5604d0aSTim J. RobbinsThe 370c5604d0aSTim J. Robbins.Vt "long int" 371c5604d0aSTim J. Robbinsargument is converted to signed decimal, unsigned octal, or unsigned 372c5604d0aSTim J. Robbinsdecimal, as if the format had been 373c5604d0aSTim J. Robbins.Cm ld , lo , 374c5604d0aSTim J. Robbinsor 375c5604d0aSTim J. Robbins.Cm lu 376c5604d0aSTim J. Robbinsrespectively. 377c5604d0aSTim J. RobbinsThese conversion characters are deprecated, and will eventually disappear. 378c5604d0aSTim J. Robbins.It Cm eE 379c5604d0aSTim J. RobbinsThe 380c5604d0aSTim J. Robbins.Vt double 381c5604d0aSTim J. Robbinsargument is rounded and converted in the style 382c5604d0aSTim J. Robbins.Sm off 383c5604d0aSTim J. Robbins.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd 384c5604d0aSTim J. Robbins.Sm on 385c5604d0aSTim J. Robbinswhere there is one digit before the 386c5604d0aSTim J. Robbinsdecimal-point character 387c5604d0aSTim J. Robbinsand the number of digits after it is equal to the precision; 388c5604d0aSTim J. Robbinsif the precision is missing, 389c5604d0aSTim J. Robbinsit is taken as 6; if the precision is 390c5604d0aSTim J. Robbinszero, no decimal-point character appears. 391c5604d0aSTim J. RobbinsAn 392c5604d0aSTim J. Robbins.Cm E 393c5604d0aSTim J. Robbinsconversion uses the letter 394c5604d0aSTim J. Robbins.Ql E 395c5604d0aSTim J. Robbins(rather than 396c5604d0aSTim J. Robbins.Ql e ) 397c5604d0aSTim J. Robbinsto introduce the exponent. 398c5604d0aSTim J. RobbinsThe exponent always contains at least two digits; if the value is zero, 399c5604d0aSTim J. Robbinsthe exponent is 00. 400c5604d0aSTim J. Robbins.Pp 401c5604d0aSTim J. RobbinsFor 402c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g , 403c5604d0aSTim J. Robbinsand 404c5604d0aSTim J. Robbins.Cm G 405c5604d0aSTim J. Robbinsconversions, positive and negative infinity are represented as 406c5604d0aSTim J. Robbins.Li inf 407c5604d0aSTim J. Robbinsand 408c5604d0aSTim J. Robbins.Li -inf 409c5604d0aSTim J. Robbinsrespectively when using the lowercase conversion character, and 410c5604d0aSTim J. Robbins.Li INF 411c5604d0aSTim J. Robbinsand 412c5604d0aSTim J. Robbins.Li -INF 413c5604d0aSTim J. Robbinsrespectively when using the uppercase conversion character. 414c5604d0aSTim J. RobbinsSimilarly, NaN is represented as 415c5604d0aSTim J. Robbins.Li nan 416c5604d0aSTim J. Robbinswhen using the lowercase conversion, and 417c5604d0aSTim J. Robbins.Li NAN 418c5604d0aSTim J. Robbinswhen using the uppercase conversion. 419c5604d0aSTim J. Robbins.It Cm fF 420c5604d0aSTim J. RobbinsThe 421c5604d0aSTim J. Robbins.Vt double 422c5604d0aSTim J. Robbinsargument is rounded and converted to decimal notation in the style 423c5604d0aSTim J. Robbins.Sm off 424c5604d0aSTim J. Robbins.Oo \- Oc Ar ddd Li \&. Ar ddd , 425c5604d0aSTim J. Robbins.Sm on 426c5604d0aSTim J. Robbinswhere the number of digits after the decimal-point character 427c5604d0aSTim J. Robbinsis equal to the precision specification. 428c5604d0aSTim J. RobbinsIf the precision is missing, it is taken as 6; if the precision is 429c5604d0aSTim J. Robbinsexplicitly zero, no decimal-point character appears. 430c5604d0aSTim J. RobbinsIf a decimal point appears, at least one digit appears before it. 431c5604d0aSTim J. Robbins.It Cm gG 432c5604d0aSTim J. RobbinsThe 433c5604d0aSTim J. Robbins.Vt double 434c5604d0aSTim J. Robbinsargument is converted in style 435c5604d0aSTim J. Robbins.Cm f 436c5604d0aSTim J. Robbinsor 437c5604d0aSTim J. Robbins.Cm e 438c5604d0aSTim J. Robbins(or 439c5604d0aSTim J. Robbins.Cm F 440c5604d0aSTim J. Robbinsor 441c5604d0aSTim J. Robbins.Cm E 442c5604d0aSTim J. Robbinsfor 443c5604d0aSTim J. Robbins.Cm G 444c5604d0aSTim J. Robbinsconversions). 445c5604d0aSTim J. RobbinsThe precision specifies the number of significant digits. 446c5604d0aSTim J. RobbinsIf the precision is missing, 6 digits are given; if the precision is zero, 447c5604d0aSTim J. Robbinsit is treated as 1. 448c5604d0aSTim J. RobbinsStyle 449c5604d0aSTim J. Robbins.Cm e 450c5604d0aSTim J. Robbinsis used if the exponent from its conversion is less than \-4 or greater than 451c5604d0aSTim J. Robbinsor equal to the precision. 452c5604d0aSTim J. RobbinsTrailing zeros are removed from the fractional part of the result; a 453c5604d0aSTim J. Robbinsdecimal point appears only if it is followed by at least one digit. 454c5604d0aSTim J. Robbins.It Cm aA 455c5604d0aSTim J. RobbinsThe 456c5604d0aSTim J. Robbins.Vt double 457c5604d0aSTim J. Robbinsargument is converted to hexadecimal notation in the style 458c5604d0aSTim J. Robbins.Sm off 459c5604d0aSTim J. Robbins.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d , 460c5604d0aSTim J. Robbins.Sm on 461c5604d0aSTim J. Robbinswhere the number of digits after the hexadecimal-point character 462c5604d0aSTim J. Robbinsis equal to the precision specification. 463c5604d0aSTim J. RobbinsIf the precision is missing, it is taken as enough to exactly 464c5604d0aSTim J. Robbinsrepresent the floating-point number; if the precision is 465c5604d0aSTim J. Robbinsexplicitly zero, no hexadecimal-point character appears. 466c5604d0aSTim J. RobbinsThis is an exact conversion of the mantissa+exponent internal 467c5604d0aSTim J. Robbinsfloating point representation; the 468c5604d0aSTim J. Robbins.Sm off 469c5604d0aSTim J. Robbins.Oo \- Oc Li 0x Ar h Li \&. Ar hhh 470c5604d0aSTim J. Robbins.Sm on 471c5604d0aSTim J. Robbinsportion represents exactly the mantissa; only denormalized 472c5604d0aSTim J. Robbinsmantissas have a zero value to the left of the hexadecimal 473c5604d0aSTim J. Robbinspoint. 474c5604d0aSTim J. RobbinsThe 475c5604d0aSTim J. Robbins.Cm p 476c5604d0aSTim J. Robbinsis a literal character 477c5604d0aSTim J. Robbins.Ql p ; 478c5604d0aSTim J. Robbinsthe exponent is preceded by a positive or negative sign 479c5604d0aSTim J. Robbinsand is represented in decimal, using only enough characters 480c5604d0aSTim J. Robbinsto represent the exponent. 481c5604d0aSTim J. RobbinsThe 482c5604d0aSTim J. Robbins.Cm A 483c5604d0aSTim J. Robbinsconversion uses the prefix 484c5604d0aSTim J. Robbins.Dq Li 0X 485c5604d0aSTim J. Robbins(rather than 486c5604d0aSTim J. Robbins.Dq Li 0x ) , 487c5604d0aSTim J. Robbinsthe letters 488c5604d0aSTim J. Robbins.Dq Li ABCDEF 489c5604d0aSTim J. Robbins(rather than 490c5604d0aSTim J. Robbins.Dq Li abcdef ) 491c5604d0aSTim J. Robbinsto represent the hex digits, and the letter 492c5604d0aSTim J. Robbins.Ql P 493c5604d0aSTim J. Robbins(rather than 494c5604d0aSTim J. Robbins.Ql p ) 495c5604d0aSTim J. Robbinsto separate the mantissa and exponent. 496c5604d0aSTim J. Robbins.It Cm C 497c5604d0aSTim J. RobbinsTreated as 498c5604d0aSTim J. Robbins.Cm c 499c5604d0aSTim J. Robbinswith the 500c5604d0aSTim J. Robbins.Cm l 501c5604d0aSTim J. Robbins(ell) modifier. 502c5604d0aSTim J. Robbins.It Cm c 503c5604d0aSTim J. RobbinsThe 504c5604d0aSTim J. Robbins.Vt int 505c5604d0aSTim J. Robbinsargument is converted to an 506c5604d0aSTim J. Robbins.Vt "unsigned char" , 507c5604d0aSTim J. Robbinsthen to a 508c5604d0aSTim J. Robbins.Vt wchar_t 509c5604d0aSTim J. Robbinsas if by 510c5604d0aSTim J. Robbins.Xr btowc 3 , 511c5604d0aSTim J. Robbinsand the resulting character is written. 512c5604d0aSTim J. Robbins.Pp 513c5604d0aSTim J. RobbinsIf the 514c5604d0aSTim J. Robbins.Cm l 515c5604d0aSTim J. Robbins(ell) modifier is used, the 516c5604d0aSTim J. Robbins.Vt wint_t 517c5604d0aSTim J. Robbinsargument is converted to a 518c5604d0aSTim J. Robbins.Vt wchar_t 519c5604d0aSTim J. Robbinsand written. 520c5604d0aSTim J. Robbins.It Cm S 521c5604d0aSTim J. RobbinsTreated as 522c5604d0aSTim J. Robbins.Cm s 523c5604d0aSTim J. Robbinswith the 524c5604d0aSTim J. Robbins.Cm l 525c5604d0aSTim J. Robbins(ell) modifier. 526c5604d0aSTim J. Robbins.It Cm s 527c5604d0aSTim J. RobbinsThe 528c5604d0aSTim J. Robbins.Vt "char *" 529c5604d0aSTim J. Robbinsargument is expected to be a pointer to an array of character type (pointer 530c5604d0aSTim J. Robbinsto a string) containing a multibyte sequence. 531c5604d0aSTim J. RobbinsCharacters from the array are converted to wide characters and written up to 532c5604d0aSTim J. Robbins(but not including) 533c5604d0aSTim J. Robbinsa terminating 534c5604d0aSTim J. Robbins.Dv NUL 535c5604d0aSTim J. Robbinscharacter; 536c5604d0aSTim J. Robbinsif a precision is specified, no more than the number specified are 537c5604d0aSTim J. Robbinswritten. 538c5604d0aSTim J. RobbinsIf a precision is given, no null character 539c5604d0aSTim J. Robbinsneed be present; if the precision is not specified, or is greater than 540c5604d0aSTim J. Robbinsthe size of the array, the array must contain a terminating 541c5604d0aSTim J. Robbins.Dv NUL 542c5604d0aSTim J. Robbinscharacter. 543c5604d0aSTim J. Robbins.Pp 544c5604d0aSTim J. RobbinsIf the 545c5604d0aSTim J. Robbins.Cm l 546c5604d0aSTim J. Robbins(ell) modifier is used, the 547c5604d0aSTim J. Robbins.Vt "wchar_t *" 548c5604d0aSTim J. Robbinsargument is expected to be a pointer to an array of wide characters 549c5604d0aSTim J. Robbins(pointer to a wide string). 550c5604d0aSTim J. RobbinsEach wide character in the string 551c5604d0aSTim J. Robbinsis written. 552c5604d0aSTim J. RobbinsWide characters from the array are written up to (but not including) 553c5604d0aSTim J. Robbinsa terminating wide 554c5604d0aSTim J. Robbins.Dv NUL 555c5604d0aSTim J. Robbinscharacter; 556c5604d0aSTim J. Robbinsif a precision is specified, no more than the number specified are 557c5604d0aSTim J. Robbinswritten (including shift sequences). 558c5604d0aSTim J. RobbinsIf a precision is given, no null character 559c5604d0aSTim J. Robbinsneed be present; if the precision is not specified, or is greater than 560c5604d0aSTim J. Robbinsthe number of characters in 561c5604d0aSTim J. Robbinsthe string, the array must contain a terminating wide 562c5604d0aSTim J. Robbins.Dv NUL 563c5604d0aSTim J. Robbinscharacter. 564c5604d0aSTim J. Robbins.It Cm p 565c5604d0aSTim J. RobbinsThe 566c5604d0aSTim J. Robbins.Vt "void *" 567c5604d0aSTim J. Robbinspointer argument is printed in hexadecimal (as if by 568c5604d0aSTim J. Robbins.Ql %#x 569c5604d0aSTim J. Robbinsor 570c5604d0aSTim J. Robbins.Ql %#lx ) . 571c5604d0aSTim J. Robbins.It Cm n 572c5604d0aSTim J. RobbinsThe number of characters written so far is stored into the 573c5604d0aSTim J. Robbinsinteger indicated by the 574c5604d0aSTim J. Robbins.Vt "int *" 575c5604d0aSTim J. Robbins(or variant) pointer argument. 576c5604d0aSTim J. RobbinsNo argument is converted. 577c5604d0aSTim J. Robbins.It Cm % 578c5604d0aSTim J. RobbinsA 579c5604d0aSTim J. Robbins.Ql % 580c5604d0aSTim J. Robbinsis written. 581c5604d0aSTim J. RobbinsNo argument is converted. 582c5604d0aSTim J. RobbinsThe complete conversion specification 583c5604d0aSTim J. Robbinsis 584c5604d0aSTim J. Robbins.Ql %% . 585c5604d0aSTim J. Robbins.El 586c5604d0aSTim J. Robbins.Pp 587c5604d0aSTim J. RobbinsThe decimal point 588c5604d0aSTim J. Robbinscharacter is defined in the program's locale (category 589c5604d0aSTim J. Robbins.Dv LC_NUMERIC ) . 590c5604d0aSTim J. Robbins.Pp 591c5604d0aSTim J. RobbinsIn no case does a non-existent or small field width cause truncation of 592c5604d0aSTim J. Robbinsa numeric field; if the result of a conversion is wider than the field 593c5604d0aSTim J. Robbinswidth, the 594c5604d0aSTim J. Robbinsfield is expanded to contain the conversion result. 595c5604d0aSTim J. Robbins.Sh SECURITY CONSIDERATIONS 596c5604d0aSTim J. RobbinsRefer to 597c5604d0aSTim J. Robbins.Xr printf 3 . 598c5604d0aSTim J. Robbins.Sh SEE ALSO 599c5604d0aSTim J. Robbins.Xr printf 3 , 600c5604d0aSTim J. Robbins.Xr setlocale 3 601c5604d0aSTim J. Robbins.Sh STANDARDS 602c5604d0aSTim J. RobbinsSubject to the caveats noted in the 603c5604d0aSTim J. Robbins.Sx BUGS 604c5604d0aSTim J. Robbinssection 605c5604d0aSTim J. Robbinsof 606c5604d0aSTim J. Robbins.Xr printf 3 , 607c5604d0aSTim J. Robbinsthe 608c5604d0aSTim J. Robbins.Fn wprintf , 609c5604d0aSTim J. Robbins.Fn fwprintf , 610c5604d0aSTim J. Robbins.Fn swprintf , 611c5604d0aSTim J. Robbins.Fn vwprintf , 612c5604d0aSTim J. Robbins.Fn vfwprintf 613c5604d0aSTim J. Robbinsand 614c5604d0aSTim J. Robbins.Fn vswprintf 615c5604d0aSTim J. Robbinsfunctions 616c5604d0aSTim J. Robbinsconform to 617c5604d0aSTim J. Robbins.St -isoC-99 . 618