File: manual050.html

package info (click to toggle)
ocaml-doc 2.04-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,820 kB
  • ctags: 997
  • sloc: makefile: 38; sh: 12
file content (83 lines) | stat: -rw-r--r-- 4,460 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
 Module Printf: formatting printing functions
</TITLE>
</HEAD>
<BODY >
<A HREF="manual049.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual051.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>

<H2>17.20&nbsp;&nbsp; Module <TT>Printf</TT>: formatting printing functions</H2><A NAME="s:Printf"></A>
<A NAME="@manual409"></A><PRE>
val fprintf: out_channel -&gt; ('a, out_channel, unit) format -&gt; 'a
</PRE>
<A NAME="@manual410"></A><BLOCKQUOTE>
<CODE>fprintf outchan format arg1 ... argN</CODE> formats the arguments
<CODE>arg1</CODE> to <CODE>argN</CODE> according to the format string <CODE>format</CODE>,
and outputs the resulting string on the channel <CODE>outchan</CODE>.<BR>
<BR>
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.<BR>
<BR>
Conversion specifications consist in the <CODE>%</CODE> character, followed
by optional flags and field widths, followed by one conversion
character. The conversion characters and their meanings are:<BR><CODE>d</CODE> or <CODE>i</CODE>: convert an integer argument to signed decimal<BR><CODE>u</CODE>: convert an integer argument to unsigned decimal<BR><CODE>x</CODE>: convert an integer argument to unsigned hexadecimal,
using lowercase letters.<BR><CODE>X</CODE>: convert an integer argument to unsigned hexadecimal,
using uppercase letters.<BR><CODE>s</CODE>: insert a string argument<BR><CODE>c</CODE>: insert a character argument<BR><CODE>f</CODE>: convert a floating-point argument to decimal notation,
in the style <CODE>dddd.ddd</CODE><BR><CODE>e</CODE> or <CODE>E</CODE>: convert a floating-point argument to decimal notation,
in the style <CODE>d.ddd e+-dd</CODE> (mantissa and exponent)<BR><CODE>g</CODE> or <CODE>G</CODE>: convert a floating-point argument to decimal notation,
in style <CODE>f</CODE> or <CODE>e</CODE>, <CODE>E</CODE> (whichever is more compact)<BR><CODE>b</CODE>: convert a boolean argument to the string <CODE>true</CODE> or <CODE>false</CODE><BR><CODE>a</CODE>: user-defined printer. Takes two arguments and apply the first
one to <CODE>outchan</CODE> (the current output channel) and to the second
argument. The first argument must therefore have type
<CODE>out_channel -&gt; 'b -&gt; unit</CODE> and the second <CODE>'b</CODE>.
The output produced by the function is therefore inserted
in the output of <CODE>fprintf</CODE> at the current point.<BR><CODE>t</CODE>: same as <CODE>%a</CODE>, but takes only one argument (with type
<CODE>out_channel -&gt; unit</CODE>) and apply it to <CODE>outchan</CODE>.<BR><CODE>%</CODE>: take no argument and output one <CODE>%</CODE> character.<BR>Refer to the C library <CODE>printf</CODE> function for the meaning of
flags and field width specifiers.<BR>
<BR>
If too few arguments are provided, printing stops just
before converting the first missing argument. 
</BLOCKQUOTE>
<PRE>
val printf: ('a, out_channel, unit) format -&gt; 'a
</PRE>
<A NAME="@manual411"></A><BLOCKQUOTE>
Same as <CODE>fprintf</CODE>, but output on <CODE>stdout</CODE>. 
</BLOCKQUOTE>
<PRE>
val eprintf: ('a, out_channel, unit) format -&gt; 'a
</PRE>
<A NAME="@manual412"></A><BLOCKQUOTE>
Same as <CODE>fprintf</CODE>, but output on <CODE>stderr</CODE>. 
</BLOCKQUOTE>
<PRE>
val sprintf: ('a, unit, string) format -&gt; 'a
</PRE>
<A NAME="@manual413"></A><BLOCKQUOTE>
Same as <CODE>fprintf</CODE>, but instead of printing on an output channel,
return a string containing the result of formatting
the arguments. 
</BLOCKQUOTE>
<PRE>
val bprintf: Buffer.t -&gt; ('a, Buffer.t, unit) format -&gt; 'a
</PRE>
<A NAME="@manual414"></A><BLOCKQUOTE>
Same as <CODE>fprintf</CODE>, but instead of printing on an output channel,
append the formatted arguments to the given extensible buffer
(see module <CODE>Buffer</CODE>). 
</BLOCKQUOTE>

<HR>
<A HREF="manual049.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual051.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>