Annotation of cci/usr/src/man/man3/printf.3s, revision 1.1

1.1     ! root        1: .TH PRINTF 3S "1 April 1981"
        !             2: .SH NAME
        !             3: printf, fprintf, sprintf \- formatted output conversion
        !             4: .SH SYNOPSIS
        !             5: .B #include <stdio.h>
        !             6: .PP
        !             7: .B printf(format
        !             8: .RB [ ,
        !             9: arg ] ...
        !            10: .B )
        !            11: .br
        !            12: .B char *format;
        !            13: .PP
        !            14: .B fprintf(stream, format
        !            15: .RB [ ,
        !            16: arg ] ...
        !            17: .B )
        !            18: .br
        !            19: .SM
        !            20: .B FILE
        !            21: .B *stream;
        !            22: .br
        !            23: .B char *format;
        !            24: .PP
        !            25: .B sprintf(s, format
        !            26: .RB [ ,
        !            27: arg ] ...
        !            28: .B )
        !            29: .br
        !            30: .B char *s, format;
        !            31: .PP
        !            32: .B #include <varargs.h>
        !            33: .br
        !            34: .B _doprnt(format, args, stream)
        !            35: .br
        !            36: .B char *format;
        !            37: .br
        !            38: .B va_list *args;
        !            39: .br
        !            40: .B FILE *stream;
        !            41: .SH DESCRIPTION
        !            42: .I Printf
        !            43: places output on the standard output stream
        !            44: .BR stdout .
        !            45: .I Fprintf
        !            46: places output on the named output
        !            47: .IR stream .
        !            48: .I Sprintf
        !            49: places `output' in the string
        !            50: .IR s ,
        !            51: followed by the character `\\0'.
        !            52: All of these routines work by calling the internal
        !            53: routine
        !            54: .B _doprnt,
        !            55: using the variable-length argument facilities of
        !            56: .IR varargs (3).
        !            57: .PP
        !            58: Each of these functions converts, formats, and prints its arguments after
        !            59: the first under control of the first argument.
        !            60: The first argument is a character string which contains two types of objects:
        !            61: plain characters, which are simply copied to the output stream,
        !            62: and conversion specifications, each of which causes conversion and printing
        !            63: of the next successive
        !            64: .I arg
        !            65: .IR printf .
        !            66: .PP
        !            67: Each conversion specification is introduced by the character
        !            68: .BR % .
        !            69: Following the
        !            70: .BR % ,
        !            71: there may be
        !            72: .TP
        !            73: .B \(bu
        !            74: an optional minus sign `\-' which specifies
        !            75: .I "left adjustment"
        !            76: of the converted value in the indicated field;
        !            77: .TP
        !            78: .B \(bu
        !            79: an optional digit string specifying a
        !            80: .I "field width;"
        !            81: if the converted value has fewer characters than the field width
        !            82: it will be blank-padded on the left (or right,
        !            83: if the left-adjustment indicator has been given) to make up the field width;
        !            84: if the field width begins with a zero,
        !            85: zero-padding will be done instead of blank-padding;
        !            86: .TP
        !            87: .B \(bu
        !            88: an optional period
        !            89: .RB ` . '
        !            90: which serves to separate the field width from the next digit string;
        !            91: .TP
        !            92: .B \(bu
        !            93: an optional digit string specifying a
        !            94: .I precision
        !            95: which specifies the number of digits to appear after the
        !            96: decimal point, for e- and f-conversion, or the maximum number of characters
        !            97: to be printed from a string;
        !            98: .TP
        !            99: .B \(bu
        !           100: the character
        !           101: .B l
        !           102: specifying that a following
        !           103: .BR d ,
        !           104: .BR o ,
        !           105: .BR x ,
        !           106: or
        !           107: .B u
        !           108: corresponds to a long integer
        !           109: .IR arg .
        !           110: .TP
        !           111: .B \(bu
        !           112: a character which indicates the type of
        !           113: conversion to be applied.
        !           114: .PP
        !           115: A field width or precision may be `*' instead of a digit string.
        !           116: In this case an integer
        !           117: .I arg
        !           118: supplies
        !           119: the field width or precision.
        !           120: .PP
        !           121: The conversion characters
        !           122: and their meanings are
        !           123: .TP
        !           124: .B dox
        !           125: The integer
        !           126: .I arg
        !           127: is converted to decimal, octal, or
        !           128: hexadecimal notation respectively.
        !           129: .TP
        !           130: .B f
        !           131: The float or double
        !           132: .I arg
        !           133: is converted to decimal notation
        !           134: in the style `[\fB\-\fR]ddd.ddd'
        !           135: where the number of d's after the decimal point
        !           136: is equal to the precision specification
        !           137: for the argument.
        !           138: If the precision
        !           139: is missing,
        !           140: 6 digits are given;
        !           141: if the precision is explicitly 0, no digits and
        !           142: no decimal point are printed.
        !           143: .TP
        !           144: .B e
        !           145: The float or double
        !           146: .I arg
        !           147: is converted in the style
        !           148: `[\fB\-\fR]d\fB.\fRddd\fBe\fR\(+-dd'
        !           149: where there is one digit before the decimal point and
        !           150: the number after is equal to the
        !           151: precision specification for the argument;
        !           152: when the precision is missing,
        !           153: 6 digits are produced.
        !           154: .TP
        !           155: .B g
        !           156: The float or double
        !           157: .I arg
        !           158: is printed in style
        !           159: .BR d ,
        !           160: in style
        !           161: .BR f ,
        !           162: or in
        !           163: style
        !           164: .BR e ,
        !           165: whichever gives full precision in minimum space.
        !           166: .TP
        !           167: .B c
        !           168: The character
        !           169: .I arg
        !           170: is printed.
        !           171: .TP
        !           172: .B s
        !           173: .I Arg
        !           174: is taken to be a string (character pointer)
        !           175: and characters from the string are printed until
        !           176: a null character or until
        !           177: the number of characters indicated by the precision
        !           178: specification is reached;
        !           179: however if the precision is 0 or missing
        !           180: all characters up to a null are printed.
        !           181: .TP
        !           182: .B u
        !           183: The unsigned integer
        !           184: .I arg
        !           185: is converted to decimal
        !           186: and printed (the result will be in the
        !           187: range 0 through MAXUINT, where MAXUINT equals 4294967295 on a Power 6/32).
        !           188: .TP
        !           189: .B %
        !           190: Print a `%'; no argument is converted.
        !           191: .PP
        !           192: In no case does a non-existent or small field width
        !           193: cause truncation of a field;
        !           194: padding takes place only if the specified field
        !           195: width exceeds the actual width.
        !           196: Characters generated by
        !           197: .I printf
        !           198: are printed by 
        !           199: .IR putc (3S).
        !           200: .PP
        !           201: .B Examples
        !           202: .br
        !           203: To print a date and time in the form `Sunday, July 3, 10:02',
        !           204: where
        !           205: .I weekday
        !           206: and
        !           207: .I month
        !           208: are pointers to null-terminated strings:
        !           209: .RS
        !           210: .HP
        !           211: .nh
        !           212: printf("%s, %s %d, %02d:%02d", weekday, month, day, hour, min);
        !           213: .RE
        !           214: .hy
        !           215: .PP
        !           216: To print
        !           217: .if n pi
        !           218: .if t \(*p
        !           219: to 5 decimals:
        !           220: .IP
        !           221: printf("pi = %.5f", 4*atan(1.0));
        !           222: .SH "SEE ALSO"
        !           223: putc(3S),
        !           224: scanf(3S),
        !           225: ecvt(3)
        !           226: .SH BUGS
        !           227: Very wide fields (>128 characters) fail.
        !           228: .br
        !           229: Due to the large size of the floating-point emulating package,
        !           230: the `e', `f' and `g' formats are only available
        !           231: with the `-lf' loader flag; otherwise a `?' is printed.

unix.superglobalmegacorp.com

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