Annotation of researchv10dc/630/man/src/p_man/man3/printf.3l, revision 1.1.1.1

1.1       root        1: .ds ZZ DEVELOPMENT PACKAGE
                      2: .TH PRINTF 3L "630 MTG"
                      3: .SH NAME
                      4: printf, fprintf, sprintf, lprintf, bprintf \- print formatted output
                      5: .SH SYNOPSIS
                      6: .B "int Printf (format"
                      7: [
                      8: .B ,
                      9: arg ] .\|.\|.
                     10: .B )
                     11: .br
                     12: .B "void printf (format"
                     13: [
                     14: .B ,
                     15: arg ] .\|.\|.
                     16: .B )
                     17: .br
                     18: .B "char \(**format;"
                     19: .PP
                     20: .B "int Fprintf (stream, format"
                     21: [
                     22: .B ,
                     23: arg ] .\|.\|.
                     24: .B )
                     25: .br
                     26: .B "void fprintf (stream, format"
                     27: [
                     28: .B ,
                     29: arg ] .\|.\|.
                     30: .B )
                     31: .br
                     32: .B "char \(**format;"
                     33: .br
                     34: .SM
                     35: .B FILE
                     36: .B \(**stream;
                     37: .PP
                     38: .B "int Sprintf (s, format"
                     39: [
                     40: .B ,
                     41: arg ] .\|.\|.
                     42: .B )
                     43: .br
                     44: .B "void sprintf (s, format"
                     45: [
                     46: .B ,
                     47: arg ] .\|.\|.
                     48: .B )
                     49: .br
                     50: .B "char \(**s, format;"
                     51: .PP
                     52: .B "int Lprintf (format"
                     53: [
                     54: .B ,
                     55: arg ] .\|.\|.
                     56: .B )
                     57: .br
                     58: .B "void lprintf (format"
                     59: [
                     60: .B ,
                     61: arg ] .\|.\|.
                     62: .B )
                     63: .br
                     64: .B "char \(**format;"
                     65: .PP
                     66: .B "int Bprintf (format"
                     67: [
                     68: .B ,
                     69: arg ] .\|.\|.
                     70: .B )
                     71: .br
                     72: .B "void bprintf (format"
                     73: [
                     74: .B ,
                     75: arg ] .\|.\|.
                     76: .B )
                     77: .br
                     78: .B "char \(**format;"
                     79: .SH DESCRIPTION
                     80: .I Lprintf\^
                     81: places output in the calling process's window.
                     82: .I Bprintf
                     83: places output at the bottom part of the 630's screen.
                     84: .I Printf\^
                     85: places output on the standard output stream
                     86: .IR stdout .
                     87: .I Fprintf\^
                     88: places output on the named output
                     89: .IR stream .
                     90: .I Sprintf\^
                     91: places ``output,''
                     92: followed by the null character
                     93: .RB ( \e0 ),
                     94: in consecutive bytes starting at
                     95: .RI \(** s ;
                     96: it is the user's responsibility to ensure that
                     97: enough storage is available.
                     98: Each function returns the number of characters
                     99: transmitted (not including the
                    100: .B \e0
                    101: in the case of
                    102: .IR Sprintf ),
                    103: or
                    104: a negative value if an output error was encountered.
                    105: The
                    106: .IR printf ,
                    107: .IR lprintf ,
                    108: .IR bprintf ,
                    109: .IR fprintf ,
                    110: and
                    111: .I sprintf
                    112: functions operate the same as those starting with a capital letter
                    113: but support only a limited number of format options and no return value.
                    114: .PP
                    115: Each of these functions
                    116: converts, formats, and prints its
                    117: .IR arg s
                    118: under control of the
                    119: .IR format .
                    120: The
                    121: .I format\^
                    122: is a character string
                    123: that contains
                    124: two types of objects:
                    125: plain characters, which are simply copied to the
                    126: output stream,
                    127: and conversion specifications,
                    128: each of which results in fetching of
                    129: zero or more
                    130: .IR arg s.
                    131: The results are undefined if there are insufficient
                    132: .IR arg s
                    133: for the format.
                    134: If the format is exhausted while
                    135: .IR arg s
                    136: remain, the excess
                    137: .IR arg s
                    138: are simply ignored.
                    139: .PP
                    140: Each conversion specification is introduced by
                    141: the character
                    142: .BR % .
                    143: After the
                    144: .BR % ,
                    145: the following
                    146: appear in sequence:
                    147: .PP
                    148: .RS
                    149: Zero or more
                    150: .IR flags ,
                    151: which modify the meaning of
                    152: the conversion specification.
                    153: .PP
                    154: An optional decimal digit string specifying a minimum
                    155: .IR "field width" .
                    156: If the converted value has fewer characters
                    157: than the field width,
                    158: it will be padded on the left (or right,
                    159: if the left-adjustment flag `\-' (described below) has been
                    160: given) to the field width.
                    161: If the field width for an
                    162: .B s
                    163: conversion is preceded by a 0, the
                    164: string is right adjusted with zero-padding on the left.
                    165: .PP
                    166: A
                    167: .I precision\^
                    168: gives
                    169: the minimum number of digits to appear for the
                    170: .BR d ,
                    171: .BR o ,
                    172: .BR u ,
                    173: .BR x ,
                    174: or
                    175: .B X
                    176: conversions,
                    177: the number of digits to appear after the
                    178: decimal point for the
                    179: .B e
                    180: and
                    181: .B f
                    182: conversions,
                    183: the maximum number of significant digits
                    184: for the
                    185: .B g
                    186: conversion,
                    187: or the maximum number of characters
                    188: to be printed from a string in
                    189: .B s
                    190: conversion.
                    191: The precision takes the form of a period
                    192: .RB ( \&. )
                    193: followed by a decimal digit string;
                    194: a null digit string is treated as zero.
                    195: .PP
                    196: An optional
                    197: .B l
                    198: (ell) specifying that a following
                    199: .BR d ,
                    200: .BR o ,
                    201: .BR u ,
                    202: .BR x ,
                    203: or
                    204: .B X
                    205: conversion character applies to a long
                    206: integer
                    207: .IR arg .
                    208: A
                    209: .B l
                    210: before any other conversion character is ignored.
                    211: .PP
                    212: A character that indicates the type of
                    213: conversion to be applied.
                    214: .RE
                    215: .PP
                    216: A field width or precision may be
                    217: indicated by an asterisk
                    218: .RB ( \(** )
                    219: instead of a digit string.
                    220: In this case, an integer
                    221: .I arg\^
                    222: supplies
                    223: the field width or precision.
                    224: The
                    225: .I arg\^
                    226: that is actually converted is not fetched until
                    227: the conversion letter is seen, so the
                    228: .IR arg s
                    229: specifying field width or precision must appear
                    230: .I before\^
                    231: the
                    232: .I arg\^
                    233: (if any) to be converted.
                    234: .PP
                    235: The flag characters and their meanings are:
                    236: .PD 0
                    237: .TP 10
                    238: .B \-
                    239: The result of the conversion will be left-justified within the field.
                    240: .TP
                    241: .B +
                    242: The result of a signed
                    243: conversion will always begin with a sign
                    244: .RB ( +
                    245: or
                    246: .BR \- ).
                    247: .TP
                    248: blank
                    249: If the first character of a signed conversion is not a sign, a blank
                    250: will be prefixed to the result.
                    251: This implies that if the blank and
                    252: .B +
                    253: flags both appear, the blank flag will be ignored.
                    254: .TP
                    255: .B #
                    256: This flag specifies that the value is to be converted
                    257: to an ``alternate form.''\ 
                    258: For
                    259: .BR c ,
                    260: .BR d ,
                    261: .BR s ,
                    262: and
                    263: .B u
                    264: conversions, the flag has no effect.
                    265: For
                    266: .B o
                    267: conversion, it increases the precision to force
                    268: the first digit of the result to be a zero.
                    269: For
                    270: .B x
                    271: or
                    272: .B X
                    273: conversion, a non-zero result will have
                    274: .B 0x
                    275: or
                    276: .B 0X
                    277: prefixed to it.
                    278: For
                    279: .BR e ,
                    280: .BR E ,
                    281: .BR f ,
                    282: .BR g ,
                    283: and
                    284: .B G
                    285: conversions, the result will always contain a decimal point,
                    286: even if no digits follow the point (normally, a decimal point
                    287: appears in the result of these conversions only if a digit
                    288: follows it).
                    289: For
                    290: .B g
                    291: and
                    292: .B G
                    293: conversions, trailing zeroes will
                    294: .I not\^
                    295: be removed from the result
                    296: (which they normally are).
                    297: .PD
                    298: .PP
                    299: The conversion characters
                    300: and their meanings are:
                    301: .PP
                    302: .PD 0
                    303: .TP 10
                    304: \f3d\fP,\f3o\fP,\f3u\fP,\f3x\fP,\f3X\fP
                    305: The integer
                    306: .I arg\^
                    307: is converted to signed decimal,
                    308: unsigned octal, decimal, or
                    309: hexadecimal notation
                    310: .RB ( x
                    311: and
                    312: .BR X ),
                    313: respectively;
                    314: the letters
                    315: .B abcdef
                    316: are used for
                    317: .B x
                    318: conversion and the letters
                    319: .SM
                    320: .B ABCDEF
                    321: for
                    322: .B X
                    323: conversion.
                    324: The precision specifies the minimum number of digits
                    325: to appear; if the value being converted can be represented
                    326: in fewer digits, it will be expanded with leading zeroes.
                    327: (For compatibility with older versions,
                    328: padding with leading zeroes may alternatively be specified by
                    329: prepending a zero to the field width.
                    330: This does not imply an octal value for the field width.)
                    331: The default precision is 1.
                    332: The result of converting a zero value with a precision
                    333: of zero is a null string.
                    334: .TP
                    335: .BR f
                    336: The float or double
                    337: .I arg\^
                    338: is converted to decimal notation
                    339: in the style ``[\f3\-\fP]ddd\f3.\fPddd,''
                    340: where the number of digits after the decimal point
                    341: is equal to the precision specification.
                    342: If the precision
                    343: is missing,
                    344: six digits are output;
                    345: if the precision is explicitly 0,
                    346: no decimal point appears.
                    347: .TP
                    348: .BR e , E
                    349: The float or double
                    350: .I arg\^
                    351: is converted in the style
                    352: ``[\f3\-\fP]d\f3.\fPddd\f3e\(+-\fPdd,''
                    353: where there is one digit before the decimal point and
                    354: the number of digits after it is equal to the
                    355: precision;
                    356: when the precision is missing,
                    357: six digits are produced;
                    358: if the precision is zero, no decimal point appears.
                    359: The
                    360: .B E
                    361: format code will produce a number with
                    362: .B E
                    363: instead of
                    364: .B e
                    365: introducing the exponent.
                    366: The exponent always contains at least two digits.
                    367: .TP
                    368: .BR g , G
                    369: The float or double
                    370: .I arg\^
                    371: is printed in style
                    372: .BR f
                    373: or
                    374: .BR e
                    375: (or in style
                    376: .B E
                    377: in the case of a
                    378: .B G
                    379: format code),
                    380: with the precision specifying the number of significant digits.
                    381: The style used depends on the value converted:
                    382: style
                    383: .B e
                    384: will be used only if the exponent resulting from
                    385: the conversion is less than \-4 or greater than the precision.
                    386: Trailing zeroes are removed from the result; a decimal point
                    387: appears only if it is followed by a digit.
                    388: .TP
                    389: .B c
                    390: The character
                    391: .I arg\^
                    392: is printed.
                    393: .TP
                    394: .B s
                    395: The
                    396: .I arg\^
                    397: is taken to be a string (character pointer)
                    398: and characters from the string are printed until
                    399: a null character
                    400: .RB ( \e0 )
                    401: is encountered or
                    402: the number of characters indicated by the precision
                    403: specification is reached.
                    404: If the precision is missing, it is taken to be infinite, so
                    405: all characters up to the first null character are printed.
                    406: A 
                    407: .SM NULL
                    408: value for
                    409: .I arg\^
                    410: will yield undefined results.
                    411: .TP
                    412: .B %
                    413: Print a
                    414: .BR % ;
                    415: no argument is converted.
                    416: .PD
                    417: .PP
                    418: In no case does a non-existent or small field width
                    419: cause truncation of a field;
                    420: if the result of a conversion is wider than the field width,
                    421: the field is simply expanded to contain the conversion result.
                    422: Characters generated by
                    423: .IR Printf\^ ,
                    424: .IR printf\^ ,
                    425: .IR Fprintf\^ ,
                    426: and
                    427: .I fprintf\^
                    428: are printed as if
                    429: .IR putc (3S)
                    430: had been called.
                    431: Characters generated by
                    432: .I Lprintf\^
                    433: and
                    434: .I lprintf\^
                    435: are printed as if
                    436: .IR lputchar (3L)
                    437: had been called.
                    438: Characters generated by
                    439: .I Bprintf
                    440: and
                    441: .I bprintf
                    442: are printed as if
                    443: .IR bputchar (3L)
                    444: had been called.
                    445: .PP
                    446: The routines
                    447: .IR printf ,
                    448: .IR lprintf ,
                    449: .IR bprintf ,
                    450: .IR fprintf ,
                    451: and
                    452: .I sprintf
                    453: support only the
                    454: .BR d ,
                    455: .BR o ,
                    456: .BR u ,
                    457: .BR x ,
                    458: .BR s ,
                    459: and
                    460: .B c
                    461: conversion characters and the optional
                    462: .BR l .
                    463: They do not support floating point format, flags, field width, or
                    464: precision options. This makes their code size small.
                    465: .SH EXAMPLES
                    466: To print a date and time in the form ``Sunday, July 3, 10:02,''
                    467: where
                    468: .I weekday\^
                    469: and
                    470: .I month\^
                    471: are pointers to null-terminated strings:
                    472: .RS
                    473: .nh
                    474: .PP
                    475: Lprintf("%s,\ %s\ %d,\ %d\fB:\fP%\fB.\fP2d",\ weekday,\ month,\ day,\ hour,\ min);
                    476: .RE
                    477: .PP
                    478: .hy 14
                    479: To print
                    480: .if n .I pi\^
                    481: .if t \(*p
                    482: to 5 decimal places:
                    483: .RS
                    484: .PP
                    485: Lprintf("pi \|= \|%\f3.\fP5f", \|4 \(** atan(1\f3.\fP0));
                    486: .RE
                    487: .SH SEE ALSO
                    488: jx(1), bputchar(3L), ecvt(3L), lputchar(3L).
                    489: .br
                    490: putc(3S) in the \fIUNIX System V Programmer's Reference Manual\fR.
                    491: .\"    @(#)printf.3l   1.1.1.1 of 4/1/87

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.