annotate docs/ccguide/printf.refentry @ 2772:0a3f4d8ea6d5

Found ENDC in wrong location in dwread.asm and dwwrite.asm. Corrected. Moved the native 6309 code in dwread.asm and dwwrite.asm into the H6309 labeled area and changed IFEQ H6309 to IFNE H6309. Also moved the 57600bps 6809 code to the default location. This change had been done in the old dwread.asm and dwwrite.asm files to make it easier to follow. Though these two files were overwritten from the HDBDOS project dwread.asm and dwwrite.asm files. So this conversion needed to be done again so it made the source easier to follow.
author drencor-xeen
date Wed, 23 Jan 2013 12:36:55 -0600
parents 8a16d38f3d94
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
1 <refentry id="printf">
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
2
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
3 <refnamediv>
603
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
4 <refname>Printf</refname>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
5 <refname>Fprintf</refname>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
6 <refname>Sprintf</refname>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
7 <refpurpose>formatted output</refpurpose>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
8 </refnamediv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
9
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
10 <refsynopsisdiv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
11
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
12 <funcsynopsis>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
13 <funcsynopsisinfo>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
14 #include &lt;stdio.h&gt;
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
15 </funcsynopsisinfo>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
16 <funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
17 <funcdef><function>printf</function></funcdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
18 <paramdef>char *<parameter>control</parameter></paramdef>
472
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 466
diff changeset
19 <paramdef>...</paramdef>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
20 </funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
21
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
22 <funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
23 <funcdef><function>fprintf</function></funcdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
24 <paramdef>FILE *<parameter>fp</parameter></paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
25 <paramdef>char *<parameter>control</parameter></paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
26 <paramdef>...</paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
27 </funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
28
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
29 <funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
30 <funcdef><function>sprintf</function></funcdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
31 <paramdef>char *<parameter>string</parameter></paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
32 <paramdef>char *<parameter>control</parameter></paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
33 <paramdef>...</paramdef>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
34 </funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
35 </funcsynopsis>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
36
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
37 </refsynopsisdiv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
38
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
39 <refsect1><title>Description</title>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
40 <para>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
41 Thse three functions are used to place numbers and strings on
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
42 the output in formatted, human readable form.
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
43 </para>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
44 <para>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
45 Fprintf places its output on the file "fp", printf on the
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
46 standard output, and sprintf in the buffer pointed to by
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
47 "string". NOTE that it is the user's responsibility to ensure
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
48 that this buffer is large enough.
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
49 </para>
603
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
50 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
51 The "control" string determines the format, type, and number
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
52 of the following arguments expected by the function. If the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
53 control does not match the arguments correctly, the results
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
54 are unpredictable.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
55 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
56 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
57 The control may contain characters to be copied directly to
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
58 the output and/or format specifications. Each format
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
59 specification causes the function to take the next successive
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
60 argument for output.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
61 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
62 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
63 A format specification consists of a "%" character followed by
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
64 (in this order):
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
65 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
66
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
67 <itemizedlist spacing="compact">
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
68 <listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
69 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
70 An optional minus sign ("-") that means left justification
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
71 in the field.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
72 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
73 </listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
74 <listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
75 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
76 An optional string of digits indication the field width
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
77 required. The field will be at least this wide and may be
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
78 wider if the conversion requires it. The field will be
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
79 padded on the left unless the above minus sign is present,
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
80 in which case it will be padded on the right. The padding
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
81 character is, by default, a space, but if the digit string
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
82 starts with a zero ("0"), it will be "0".
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
83 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
84 </listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
85 <listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
86 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
87 An optional dot (".") and a digit string, the precision,
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
88 which for floating point arguments indicates the number
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
89 of digits to follow the decimal point on conversion, and
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
90 for strings, the maximum number of characters from the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
91 string argument are to be printed.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
92 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
93 </listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
94 <listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
95 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
96 An optional character "l" indicates that the following
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
97 "d","x", or "o" is the specification of a long integer
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
98 argument. NOTE that in order for the printing of long
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
99 integers to take place, the source code must have in it
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
100 somewhere the statement pflinit(), which causes routines
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
101 to be linked from the library.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
102 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
103 </listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
104 <listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
105 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
106 A conversion character which shows the type of the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
107 argument and the desired conversion. The recognized
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
108 conversion characters are:
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
109 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
110
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
111 <informaltable frame="none">
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
112 <tgroup cols="2">
640
8a16d38f3d94 Convert to Docbook XML format
roug
parents: 603
diff changeset
113 <colspec colwidth="0.5in"/>
8a16d38f3d94 Convert to Docbook XML format
roug
parents: 603
diff changeset
114 <colspec colwidth="3in"/>
603
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
115 <tbody>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
116 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
117 <entry>d,o,x,X</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
118 <entry>The argument is an integer and the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
119 conversion is to decimal, octal, or
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
120 hexadecimal, respectively. "X" prints hex
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
121 and alpha in upper case.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
122 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
123 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
124 <entry>u</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
125 <entry>The argument is an integer and the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
126 conversion is to an unsigned decimal in
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
127 the range 0 to 65535.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
128 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
129 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
130 <entry>f</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
131 <entry>The argument is a double, and the form of
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
132 the conversion is "[-]nnn.nnn". Where the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
133 digits after the decimal point are
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
134 specified as above. If not specified, the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
135 precision defaults to six digits. If the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
136 precision is 0, no decimal point or
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
137 following digits are printed.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
138 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
139 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
140 <entry>e,E</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
141 <entry>The argument is a double and the form of
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
142 the conversion is "[-]n.nnne(+or-)nn"; one
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
143 digit before the decimal point, and the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
144 precision controls the number following.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
145 "E" prints the "e" in upper case.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
146 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
147 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
148 <entry>g,G</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
149 <entry>The argument is a double, and either the
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
150 "f" format or the "e" format is chosen,
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
151 whichever is the shortest. If the "G"
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
152 format is used, the "e" is printed in
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
153 upper case.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
154 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
155 </tbody>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
156 </tgroup>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
157 </informaltable>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
158
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
159 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
160 NOTE in each of the above double conversions, the last digit is
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
161 rounded.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
162 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
163 <para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
164 ALSO NOTE that in order for the printing of floats or doubles
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
165 to take place, the source program <emphasis>must</emphasis> have the statement
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
166 pffinit() somewhere.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
167 </para>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
168
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
169 <informaltable frame="none">
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
170 <tgroup cols="2">
640
8a16d38f3d94 Convert to Docbook XML format
roug
parents: 603
diff changeset
171 <colspec colwidth="0.5in"/>
8a16d38f3d94 Convert to Docbook XML format
roug
parents: 603
diff changeset
172 <colspec colwidth="3in"/>
603
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
173 <tbody>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
174 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
175 <entry>c</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
176 <entry>The argument as a character.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
177 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
178 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
179 <entry>s</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
180 <entry>The argument is a pointer to a string.
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
181 Characters from the string are printed up
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
182 to a null character, or untill the number of
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
183 characters indicated by the precision have
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
184 been printed. If the precision is 0 or
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
185 missing, the characters are not counted.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
186 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
187 <row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
188 <entry>%</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
189 <entry>No argument corresponding; "%" is printed.</entry>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
190 </row>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
191 </tbody>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
192 </tgroup>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
193 </informaltable>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
194
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
195 </listitem>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
196 </itemizedlist>
e9578f62b346 All refentries finished.
roug
parents: 542
diff changeset
197
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
198 </refsect1>
542
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
199
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
200 <refsect1><title>See Also</title>
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
201 <para>
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
202 Kernighan &amp; Ritchie pages 145-147.
640
8a16d38f3d94 Convert to Docbook XML format
roug
parents: 603
diff changeset
203 <link linkend="putc">putc()</link>,
542
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
204 <link linkend="scanf">scanf()</link>
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
205 </para>
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
206 </refsect1>
73319ee6a57e All "See Also" implemented
roug
parents: 472
diff changeset
207
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
208 </refentry>