Module Printf


structure Printf = struct ... end 
Formatted output functions.

val fprintf : Pervasives.out_channel -> ('a, Pervasives.out_channel, unit) format -> 'a
fprintf outchan format arg1 ... argN formats the arguments arg1 to argN according to the format string format, and outputs the resulting string on the channel outchan.
The format is a character string which contains two types of objects: plain characters, which are simply copied to the output channel, and conversion specifications, each of which causes conversion and printing of one argument.
Conversion specifications consist in the % character, followed by optional flags and field widths, followed by one or two conversion character. The conversion characters and their meanings are: The optional flags include: The field widths are composed of an optional integer literal indicating the minimal width of the result, possibly followed by a dot . and another integer literal indicating how many digits follow the decimal point in the 0.000000, 0.000000e+00, and %E conversions. For instance, 0 prints an integer, prefixing it with spaces to fill at least 6 characters; and 0.0000 prints a float with 4 fractional digits. Each or both of the integer literals can also be specified as a *, in which case an extra integer argument is taken to specify the corresponding width or precision.
Warning: if too few arguments are provided, for instance because the printf function is partially applied, the format is immediately printed up to the conversion of the first missing argument; printing will then resume when the missing arguments are provided. For example, List.iter (printf "x=0 y=0 " 1) [2;3] prints x=1 y=2 3 instead of the expected x=1 y=2 x=1 y=3. To get the expected behavior, do List.iter (fun y -> printf "x=0 y=0 " 1 y) [2;3].
val printf : ('a, Pervasives.out_channel, unit) format -> 'a
Same as Printf.fprintf, but output on stdout.
val eprintf : ('a, Pervasives.out_channel, unit) format -> 'a
Same as Printf.fprintf, but output on stderr.
val sprintf : ('a, unit, string) format -> 'a
Same as Printf.fprintf, but instead of printing on an output channel, return a string containing the result of formatting the arguments.
val bprintf : Buffer.t -> ('a, Buffer.t, unit) format -> 'a
Same as Printf.fprintf, but instead of printing on an output channel, append the formatted arguments to the given extensible buffer (see module Buffer).