home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man3 / printf.3 < prev    next >
Encoding:
Text File  |  1975-06-26  |  3.3 KB  |  139 lines

  1. .th PRINTF III 9/17/73
  2. .sh NAME
  3. printf \*- formatted print
  4. .sh SYNOPSIS
  5. .ft B
  6. printf(format, arg\s6\d1\u\s10, ...);
  7. .br
  8. char *format;
  9. .ft R
  10. .sh DESCRIPTION
  11. .it Printf
  12. converts, formats, and prints its arguments after the first
  13. under control of the first argument.
  14. The first argument is a character string
  15. which contains
  16. two types of objects:
  17. plain characters, which are simply copied to the
  18. output stream,
  19. and conversion specifications,
  20. each of which causes conversion and printing
  21. of the next successive argument to
  22. .it printf.
  23. .s3
  24. Each conversion specification is introduced by
  25. the character \fB%\fR.
  26. Following the \fB%\fR, there may be
  27. .s3
  28. .lp +6 2
  29. \*-    an optional minus sign ``\*-'' which specifies
  30. .it "left adjustment"
  31. of the converted argument
  32. in the
  33. indicated field;
  34. .s3
  35. .lp +6 2
  36. \*-    an optional digit string specifying a
  37. .it "field width;"
  38. if the converted argument has fewer characters
  39. than the field width
  40. it will be blank-padded on the left (or right,
  41. if the left-adjustment indicator has been
  42. given) to make up the field width;
  43. .s3
  44. .lp +6 2
  45. \*-    an optional period ``\fB.\fR'' which serves to
  46. separate the field width from the
  47. next digit string;
  48. .s3
  49. .lp +6 2
  50. \*-    an optional digit string
  51. .it "(precision)"
  52. which specifies
  53. the number of digits to appear after the
  54. decimal point, for e- and f-conversion,
  55. or the maximum number of characters
  56. to be printed from a string;
  57. .s3
  58. .lp +6 2
  59. \*-    a character which indicates the type of
  60. conversion to be applied.
  61. .s3
  62. .i0
  63. The conversion characters
  64. and their meanings are
  65. .s3
  66. .lp +6 3
  67. d
  68. .lp +6 3
  69. o
  70. .lp +6 3
  71. x    The integer argument is converted to decimal, octal, or
  72. hexadecimal notation respectively.
  73. .s3
  74. .lp +6 3
  75. f    The argument is converted to decimal notation
  76. in the style ``[\fB\*-\fR]ddd.ddd''
  77. where the number of d's after the decimal point
  78. is equal to the precision specification
  79. for the argument.
  80. If the precision
  81. is missing,
  82. 6 digits are given;
  83. if the precision is explicitly 0, no digits and
  84. no decimal point are printed.
  85. The argument should be
  86. .it float
  87. or
  88. .it double.
  89. .s3
  90. .lp +6 3
  91. e    The argument is converted in the style
  92. ``[\fB\*-\fR]d\fB.\fRddd\fBe\fR\(+-dd''
  93. where there is one digit before the decimal point and
  94. the number after is equal to the
  95. precision specification for the argument;
  96. when the precision is missing,
  97. 6 digits are produced.
  98. The argument should be a
  99. .it float
  100. or
  101. .it double
  102. quantity.
  103. .s3
  104. .lp +6 3
  105. c    The argument character is printed.
  106. .s3
  107. .lp +6 3
  108. s    The argument is taken to be a string (character pointer)
  109. and characters from the string are printed until
  110. a null character or until
  111. the number of characters indicated by the precision
  112. specification is reached;
  113. however if the precision is 0 or missing
  114. all characters up to a null are printed.
  115. .s3
  116. .lp +6 3
  117. l    The argument is taken to be an unsigned
  118. integer which is converted to decimal
  119. and printed (the result will be in the
  120. range 0 to 65535).
  121. .s3
  122. .i0
  123. If no recognizable character appears after the \fB%\fR,
  124. that character is printed;
  125. thus \fb%\fR may be printed by use of the
  126. string \fB%%\fR.
  127. In no case does a non-existent or small field width
  128. cause truncation of a field;
  129. padding takes place only if the specified field
  130. width exceeds the actual width.
  131. Characters generated by
  132. .it printf
  133. are printed by calling
  134. .it putchar.
  135. .sh "SEE ALSO"
  136. putchar (III)
  137. .sh BUGS
  138. Very wide fields (>128 characters) fail.
  139.