diff options
author | 2000-04-20 01:39:31 +0000 | |
---|---|---|
committer | 2000-04-20 01:39:31 +0000 | |
commit | aa86bf2d6802741b82abbadd8b93f15e93018443 (patch) | |
tree | 51ed78b35a0b80645fd9da45de68dca44508f8b8 /lib/libc/stdio/printf.3 | |
parent | Remove NetBSD ifdefs here too. (diff) | |
download | wireguard-openbsd-aa86bf2d6802741b82abbadd8b93f15e93018443.tar.xz wireguard-openbsd-aa86bf2d6802741b82abbadd8b93f15e93018443.zip |
Flesh out all of the stdio man pages.
Diffstat (limited to 'lib/libc/stdio/printf.3')
-rw-r--r-- | lib/libc/stdio/printf.3 | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3 index 66c0aa25ea6..c064bed7f73 100644 --- a/lib/libc/stdio/printf.3 +++ b/lib/libc/stdio/printf.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: printf.3,v 1.25 2000/04/18 03:01:35 aaron Exp $ +.\" $OpenBSD: printf.3,v 1.26 2000/04/20 01:39:32 aaron Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -79,23 +79,30 @@ .Sh DESCRIPTION The .Fn printf -family of functions produces output according to a +family of functions produce output according to the given .Fa format as described below. +This format may contain +.Dq conversion specifiers ; +the results of such conversions, if any, depend on the arguments +following the +.Fa format +string. +.Pp +The .Fn printf and .Fn vprintf -write output to -.Em stdout , -the standard output stream; +functions write output to the standard output stream, +.Em stdout ; .Fn fprintf and .Fn vfprintf -write output to the given output +write output to the supplied stream pointer .Fa stream ; .Fn sprintf , .Fn snprintf , -.Fn vsprintf +.Fn vsprintf , and .Fn vsnprintf write to the character string @@ -113,8 +120,7 @@ string that specifies how subsequent arguments .Xr stdarg 3 ) are converted for output. .Pp -These functions return -the number of characters printed +These functions return the number of characters printed (not including the trailing .Ql \e0 used to end output to strings). @@ -122,8 +128,7 @@ used to end output to strings). .Fn asprintf and .Fn vasprintf -return a pointer to a buffer sufficiently large to hold the -string in the +return a pointer to a buffer sufficiently large to hold the string in the .Fa ret argument. This pointer should be passed to @@ -132,7 +137,7 @@ to release the allocated storage when it is no longer needed. If sufficient space cannot be allocated, these functions will return \-1 and set .Fa ret -to be a NULL pointer. +to be a null pointer. .Pp If .Fn asprintf @@ -142,7 +147,7 @@ are given a .Fa size of 0, they set .Fa ret -to be a NULL pointer. +to be a null pointer. .Pp .Fn snprintf and @@ -170,11 +175,10 @@ ordinary .\" multibyte characters (not .Cm % ) , -which are copied unchanged to the output stream; +which are copied unchanged to the output stream, and conversion specifications, each of which results in fetching zero or more subsequent arguments. -Each conversion specification is introduced by -the character +Each conversion specification is introduced by the character .Cm % . The arguments must correspond properly (after type promotion) with the conversion specifier. @@ -184,7 +188,7 @@ the following appear in sequence: .Bl -bullet .It An optional field, consisting of a decimal digit string followed by a -.Cm $ , +.Cm $ specifying the next argument to access. If this field is not provided, the argument following the last argument accessed will be used. @@ -194,8 +198,8 @@ Arguments are numbered starting at Zero or more of the following flags: .Bl -hyphen .It -A -.Cm # +A hash +.Ql Cm # character specifying that the value should be converted to an ``alternate form''. For @@ -336,13 +340,13 @@ specifying that a following or .Cm X conversion corresponds to a -.Em short int +.Li short int or -.Em unsigned short int +.Li unsigned short int argument, or that a following .Cm n conversion corresponds to a pointer to a -.Em short int +.Li short int argument. .It The optional character @@ -356,13 +360,13 @@ The optional character or .Cm X conversion applies to a pointer to a -.Em long int +.Li long int or -.Em unsigned long int +.Li unsigned long int argument, or that a following .Cm n conversion corresponds to a pointer to a -.Em long int +.Li long int argument. .It The optional character @@ -376,13 +380,13 @@ specifying that a following or .Cm X conversion corresponds to a -.Em quad int +.Li quad int or -.Em unsigned quad int +.Li unsigned quad int argument, or that a following .Cm n conversion corresponds to a pointer to a -.Em quad int +.Li quad int argument. .It The character @@ -395,7 +399,7 @@ specifying that a following or .Cm G conversion corresponds to a -.Em long double +.Li long double argument (but note that long double values are not currently supported by the .Tn VAX @@ -414,7 +418,7 @@ or an asterisk followed by one or more decimal digits and a instead of a digit string. In this case, an -.Em int +.Li int argument supplies the field width or precision. A negative field width is treated as a left adjustment flag followed by a positive field width; a negative precision is treated as though it were @@ -426,7 +430,7 @@ The conversion specifiers and their meanings are: .Bl -tag -width "diouxX" .It Cm diouxX The -.Em int +.Li int (or appropriate variant) argument is converted to signed decimal .Pf ( Cm d and @@ -454,7 +458,7 @@ appear; if the converted value requires fewer digits, it is padded on the left with zeros. .It Cm DOU The -.Em long int +.Li long int argument is converted to signed decimal, unsigned octal, or unsigned decimal, as if the format had been .Cm ld , @@ -465,7 +469,7 @@ respectively. These conversion characters are deprecated, and will eventually disappear. .It Cm eE The -.Em double +.Li double argument is rounded and converted in the style .Sm off .Pf [\-]d Cm \&. No ddd Cm e No \\*(Pmdd @@ -487,7 +491,7 @@ The exponent always contains at least two digits; if the value is zero, the exponent is 00. .It Cm f The -.Em double +.Li double argument is rounded and converted to decimal notation in the style .Sm off .Pf [-]ddd Cm \&. No ddd , @@ -499,7 +503,7 @@ explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it. .It Cm gG The -.Em double +.Li double argument is converted in style .Cm f or @@ -520,29 +524,29 @@ Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit. .It Cm c The -.Em int +.Li int argument is converted to an -.Em unsigned char , +.Li unsigned char , and the resulting character is written. .It Cm s The -.Dq Em char * +.Li char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating -.Dv NUL +.Tn NUL character; if a precision is specified, no more than the number specified are written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating -.Dv NUL +.Tn NUL character. .It Cm p The -.Dq Em void * +.Li void * pointer argument is printed in hexadecimal (as if by .Ql %#x or @@ -550,7 +554,7 @@ or .It Cm n The number of characters written so far is stored into the integer indicated by the -.Dq Em int * +.Li int * (or variant) pointer argument. No argument is converted. .It Cm % @@ -568,9 +572,9 @@ field is expanded to contain the conversion result. .Sh EXAMPLES To print a date and time in the form `Sunday, July 3, 10:02', where -.Em weekday +.Va weekday and -.Em month +.Va month are pointers to strings: .Bd -literal -offset indent #include <stdio.h> |