home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / printf.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  2.5 KB  |  50 lines  |  [TEXT/MPS ]

  1. (* Formatting printing functions *)
  2.  
  3. #open "io";;
  4.  
  5. value fprintf: out_channel -> string -> 'a
  6.         (* [fprintf outchan format arg1 ... argN] formats the arguments
  7.            [arg1] to [argN] according to the format string [format],
  8.            and outputs the resulting string on the channel [outchan].
  9.            The format is a character string which contains two types of
  10.            objects:  plain  characters, which are simply copied to the
  11.            output channel, and conversion specifications, each of which
  12.            causes  conversion and printing of one argument.
  13.            Conversion specifications consist in the [%] character, followed
  14.            by optional flags and field widths, followed by one conversion
  15.            character. The conversion characters and their meanings are:
  16. -          [d] or [i]: convert an integer argument to signed decimal
  17. -          [u]: convert an integer argument to unsigned decimal
  18. -          [x]: convert an integer argument to unsigned hexadecimal,
  19.                 using lowercase letters.
  20. -          [X]: convert an integer argument to unsigned hexadecimal,
  21.                 using uppercase letters.
  22. -          [s]: insert a string argument
  23. -          [c]: insert a character argument
  24. -          [f]: convert a floating-point argument to decimal notation,
  25.                 in the style [dddd.ddd]
  26. -          [e] or [E]: convert a floating-point argument to decimal notation,
  27.                 in the style [d.ddd e+-dd] (mantissa and exponent)
  28. -          [g] or [G]: convert a floating-point argument to decimal notation,
  29.                 in style [f] or [e], [E] (whichever is more compact)
  30. -          [b]: convert a boolean argument to the string [true] or [false]
  31. -          Refer to the C library [printf] function for the meaning of
  32.            flags and field width specifiers.
  33.            The exception [Invalid_argument] is raised if the types of the
  34.            provided arguments do not match the format. The exception is
  35.            also raised if too many arguments are provided. If too few
  36.            arguments are provided, printing stops just before converting
  37.            the first missing argument. *)
  38.  
  39.   and printf: string -> 'a
  40.         (* Same as [fprintf], but output on [std_out]. *)
  41.  
  42.   and fprint: out_channel -> string -> unit
  43.         (* Print the given string on the given output channel, without
  44.            any formatting. *)
  45.  
  46.   and print: string -> unit
  47.         (* Print the given string on [std_out], without any formatting.
  48.        This is the same function as [print_string] of module [io]. *)
  49. ;;
  50.