OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / printf.3
1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\"
24 .\" Earlier versions of this page influenced the present text.
25 .\" It was derived from a Berkeley page with version
26 .\"       @(#)printf.3    6.14 (Berkeley) 7/30/91
27 .\" converted for Linux by faith@cs.unc.edu, updated by
28 .\" Helmut.Geyer@iwr.uni-heidelberg.de, agulbra@troll.no and Bruno Haible.
29 .\"
30 .\" 1999-11-25 aeb - Rewritten, using SUSv2 and C99.
31 .\" 2000-07-26 jsm28@hermes.cam.ac.uk - three small fixes
32 .\" 2000-10-16 jsm28@hermes.cam.ac.uk - more fixes
33 .\"
34 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi all rights reserved.
35 .\" Translated 1998-02-17, YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
36 .\" Updated 2000-10-02, Kentaro Shirakata <argrath@ub32.org>
37 .\" Updated 2001-01-29, Kentaro Shirakata <argrath@ub32.org>
38 .\" Updated 2002-01-03, Kentaro Shirakata <argrath@ub32.org>
39 .\" Updated 2002-10-17, Kentaro Shirakata <argrath@ub32.org>
40 .\" Updated 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
41 .\" Updated 2006-07-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
42 .\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
43 .\" Updated 2009-03-03, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.19
44 .\"
45 .\" WORD: conversion specifier  ÊÑ´¹»ØÄê»Ò
46 .\" WORD: length modifier       Ä¹¤µ½¤¾þ»Ò
47 .\"
48 .TH PRINTF 3  2008-12-19 "GNU" "Linux Programmer's Manual"
49 .\"O .SH NAME
50 .SH Ì¾Á°
51 .\"O printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf,
52 .\"O vsnprintf \- formatted output conversion
53 printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf,
54 vsnprintf \- »ØÄꤵ¤ì¤¿½ñ¼°¤ËÊÑ´¹¤·¤Æ½ÐÎϤò¹Ô¤¦
55 .\"O .SH SYNOPSIS
56 .SH ½ñ¼°
57 .B #include <stdio.h>
58 .sp
59 .BI "int printf(const char *" format ", ...);"
60 .br
61 .BI "int fprintf(FILE *" stream ", const char *" format ", ...);"
62 .br
63 .BI "int sprintf(char *" str ", const char *" format ", ...);"
64 .br
65 .BI "int snprintf(char *" str ", size_t " size ", const char *" format ", ...);"
66 .sp
67 .B #include <stdarg.h>
68 .sp
69 .BI "int vprintf(const char *" format ", va_list " ap );
70 .br
71 .BI "int vfprintf(FILE *" stream ", const char *" format ", va_list " ap );
72 .br
73 .BI "int vsprintf(char *" str ", const char *" format ", va_list " ap );
74 .br
75 .BI "int vsnprintf(char *" str ", size_t " size ", const char *" format \
76 ", va_list " ap );
77 .sp
78 .in -4n
79 .\"O Feature Test Macro Requirements for glibc (see
80 .\"O .BR feature_test_macros (7)):
81 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
82 .RB ( feature_test_macros (7)
83 »²¾È):
84 .in
85 .sp
86 .ad l
87 .BR snprintf (),
88 .BR vsnprintf ():
89 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or
90 .I "cc -std=c99"
91 .ad b
92 .\"O .SH DESCRIPTION
93 .SH ÀâÌÀ
94 .\"O The functions in the
95 .\"O .BR printf ()
96 .\"O family produce output according to a
97 .\"O .I format
98 .\"O as described below.
99 .BR printf ()
100 ´Ø¿ô¥°¥ë¡¼¥×¤Ï¡¢°Ê²¼¤Ç½Ò¤Ù¤ë¤è¤¦¤Ë¡¢
101 .I format
102 ¤Ë½¾¤Ã¤Æ½ÐÎϤòÀ¸À®¤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
103 .\"O The functions
104 .\"O .BR printf ()
105 .\"O and
106 .\"O .BR vprintf ()
107 .\"O write output to
108 .\"O .IR stdout ,
109 .\"O the standard output stream;
110 .\"O .BR fprintf ()
111 .\"O and
112 .\"O .BR vfprintf ()
113 .\"O write output to the given output
114 .\"O .IR stream ;
115 .\"O .BR sprintf (),
116 .\"O .BR snprintf (),
117 .\"O .BR vsprintf ()
118 .\"O and
119 .\"O .BR vsnprintf ()
120 .\"O write to the character string
121 .\"O .IR str .
122 .BR printf ()
123 ¤È
124 .BR vprintf ()
125 ¤Ï½ÐÎϤò
126 .I stdout
127 (ɸ½à½ÐÎÏ¥¹¥È¥ê¡¼¥à) ¤Ë½ñ¤­½Ð¤¹¡£
128 .BR fprintf ()
129 ¤È
130 .BR vfprintf ()
131 ¤Ï½ÐÎϤò»ØÄꤵ¤ì¤¿½ÐÎÏ
132 .I stream
133 ¤Ë½ñ¤­½Ð¤¹¡£
134 .BR sprintf (),
135 .BR snprintf (),
136 .BR vsprintf (),
137 .BR vsnprintf ()
138 ¤Ï½ÐÎϤòʸ»úÎó
139 .IR str
140 ¤Ë½ñ¤­¹þ¤à¡£
141 .PP
142 .\"O The functions
143 .\"O .BR snprintf ()
144 .\"O and
145 .\"O .BR vsnprintf ()
146 .\"O write at most
147 .\"O .I size
148 .\"O bytes (including the trailing null byte (\(aq\e0\(aq)) to
149 .\"O .IR str .
150 .BR snprintf ()
151 ¤È
152 .BR vsnprintf ()
153 ¤ÏºÇÂç¤Ç
154 .I size
155 ¥Ð¥¤¥È¤ò
156 .I str
157 ¤Ë½ñ¤­¹þ¤à
158 .RI ( size
159 ¤Ë¤Ïʸ»úÎó¤ò½ªÃ¼¤¹¤ë \(aq\e0\(aq ¤â¤ò´Þ¤Þ¤ì¤ë)¡£
160 .PP
161 .\"O The functions
162 .\"O .BR vprintf (),
163 .\"O .BR vfprintf (),
164 .\"O .BR vsprintf (),
165 .\"O .BR vsnprintf ()
166 .\"O are equivalent to the functions
167 .\"O .BR printf (),
168 .\"O .BR fprintf (),
169 .\"O .BR sprintf (),
170 .\"O .BR snprintf (),
171 .\"O respectively, except that they are called with a
172 .\"O .I va_list
173 .\"O instead of a variable number of arguments.
174 .\"O These functions do not call the
175 .\"O .I va_end
176 .\"O macro.
177 .\"O Because they invoke the
178 .\"O .I va_arg
179 .\"O macro, the value of
180 .\"O .I ap
181 .\"O is undefined after the call.
182 .\"O See
183 .\"O .BR stdarg (3).
184 .BR vprintf (),
185 .BR vfprintf (),
186 .BR vsprintf (),
187 .BR vsnprintf ()
188 ¤Î³Æ´Ø¿ô¤Ï¤½¤ì¤¾¤ì
189 .BR printf (),
190 .BR fprintf (),
191 .BR sprintf (),
192 .BR snprintf (),
193 ¤Î³Æ´Ø¿ô¤ÈÅù²Á¤Ç¤¢¤ê¡¢²ÄÊÑ¿ô°ú¤­¿ô¤ÎÂå¤ï¤ê¤Ë
194 .I va_list
195 ¤ò°ú¤­¿ô¤È¤·¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ëÅÀ¤À¤±¤¬°Û¤Ê¤ë¡£
196 ¤³¤ì¤é¤Î´Ø¿ô¤Ç¤Ï
197 .I va_end
198 ¥Þ¥¯¥í¤Ï¸Æ¤Ó½Ð¤µ¤ì¤Ê¤¤¡£
199 ¤³¤ì¤é¤Î´Ø¿ô¤Ï
200 .I va_arg
201 ¤ò¸Æ¤Ó½Ð¤¹¤Î¤Ç¡¢¸Æ¤Ó½Ð¤·¸å¤Î
202 .I ap
203 ¤ÎÃͤÏ̤ÄêµÁ¤Ç¤¢¤ë¡£
204 .BR stdarg (3)
205 ¤ò»²¾È¤Î¤³¤È¡£
206 .PP
207 .\"O These eight functions write the output under the control of a
208 .\"O .I format
209 .\"O string that specifies how subsequent arguments (or arguments accessed via
210 .\"O the variable-length argument facilities of
211 .\"O .BR stdarg (3))
212 .\"O are converted for output.
213 ¤³¤ì¤é¤Î 8 ¤Ä¤Î´Ø¿ô¤Ï
214 .I format
215 ʸ»úÎó¤ÎÀ©¸æ¤Ë½¾¤Ã¤Æ½ÐÎϤò½ñ¤­½Ð¤¹¡£
216 .I format
217 ʸ»úÎó¤Ï¡¢¤³¤ì¤Ë³¤¯°ú¤­¿ô (¤Þ¤¿¤Ï
218 .BR stdarg (3)
219 ¤Î²ÄÊÑĹ°ú¤­¿ôµ¡¹½¤ò»È¤Ã¤Æ¥¢¥¯¥»¥¹¤Ç¤­¤ë°ú¤­¿ô)
220 ¤ò¤É¤Î¤è¤¦¤ËÊÑ´¹¤·¤Æ½ÐÎϤ¹¤ë¤«¤ò»ØÄꤹ¤ë¡£
221
222 .\"O C99 and POSIX.1-2001 specify that the results are undefined if a call to
223 .\"O .BR sprintf (),
224 .\"O .BR snprintf (),
225 .\"O .BR vsprintf (),
226 .\"O or
227 .\"O .BR vsnprintf ()
228 .\"O would cause copying to take place between objects that overlap
229 .\"O (e.g., if the target string array and one of the supplied input arguments
230 .\"O refer to the same buffer).
231 .\"O See NOTES.
232 C99 ¤È POSIX.1-2001 ¤Ç¤Ï¡¢
233 .BR sprintf (),
234 .BR snprintf (),
235 .BR vsprintf (),
236 .BR vsnprintf ()
237 ¤Î¸Æ¤Ó½Ð¤·¤Ç¡¢ÈϰϤ¬½ÅÊ£¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È´Ö¤Ç¥³¥Ô¡¼¤¬È¯À¸¤¹¤ë¾ì¹ç¤Î
238 ·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¤Èµ¬Äꤵ¤ì¤Æ¤¤¤ë (Î㤨¤Ð¡¢½ÐÎÏÀè¤Îʸ»úÎó¤ÈÆþÎϤµ¤ì¤¿
239 °ú¤­¿ô¤Î°ì¤Ä¤¬Æ±¤¸¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤Ê¤É¤Ç¤¢¤ë)¡£
240 ¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¡£
241 .\"O .SS "Return value"
242 .SS ÊÖ¤êÃÍ
243 .\"O Upon successful return, these functions return the number of characters
244 .\"O printed (not including the
245 .\"O trailing \(aq\e0\(aq used to end output to strings).
246 À®¸ù»þ¤Ë¤Ï¡¢¾åµ­¤Î´Ø¿ô¤Ï½ñ¤­¹þ¤Þ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹
247 (ʸ»úÎó¤ÎºÇ¸å¤ò¼¨¤¹¤¿¤á¤Ë»ÈÍѤ¹¤ë \(aq\e0\(aq ¤Ï¿ô¤Ë´Þ¤Þ¤ì¤Ê¤¤)¡£
248
249 .\"O The functions
250 .\"O .BR snprintf ()
251 .\"O and
252 .\"O .BR vsnprintf ()
253 .\"O do not write more than
254 .\"O .I size
255 .\"O bytes (including the trailing \(aq\e0\(aq).
256 .\"O If the output was truncated due to this limit then the return value
257 .\"O is the number of characters (not including the trailing \(aq\e0\(aq)
258 .\"O which would have been written to the final string if enough space
259 .\"O had been available.
260 .\"O Thus, a return value of
261 .\"O .I size
262 .\"O or more means that the output was truncated.
263 .\"O (See also below under NOTES.)
264 .BR snprintf ()
265 ¤È
266 .BR vsnprintf ()
267 ¤Ï¡¢
268 .I size
269 ¥Ð¥¤¥È¤ò±Û¤¨¤ëʸ»ú¿ô¤ò½ñ¤­¹þ¤Þ¤Ê¤¤
270 .RI ( size
271 ¤Ë¤Ïʸ»úÎó¤ò½ªÃ¼¤¹¤ë \(aq\e0\(aq ¤â¤ò´Þ¤Þ¤ì¤ë)¡£
272 ¤³¤ÎÀ©¸Â¤Ë¤è¤Ã¤Æ½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
273 ¤â¤·½½Ê¬¤Ê¥¹¥Ú¡¼¥¹¤¬¤¢¤ì¤Ð½ñ¤­¹þ¤Þ¤ì¤¿¤Ç¤¢¤í¤¦Ê¸»ú¤Î¸Ä¿ô
274 (ʸ»úÎó¤ò½ªÃ¼¤¹¤ë \(aq\e0\(aq ¤ò½ü¤¯) ¤òÊÖ¤¹¡£
275 ½¾¤Ã¤Æ¡¢ÊÖ¤êÃͤ¬
276 .I size
277 °Ê¾å¤À¤Ã¤¿¾ì¹ç¡¢½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¤³¤È¤ò°ÕÌ£¤¹¤ë
278 (¸å½Ò¤ÎÃí°Õ¤â»²¾È¤Î¤³¤È)¡£
279
280 .\"O If an output error is encountered, a negative value is returned.
281 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢Éé¤Î¿ô¤òÊÖ¤¹¡£
282 .\"O .SS "Format of the format string"
283 .SS ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Î¥Õ¥©¡¼¥Þ¥Ã¥È
284 .\"O The format string is a character string, beginning and ending
285 .\"O in its initial shift state, if any.
286 ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Ïʸ»ú¤ÎÎó¤Ç¡¢
287 (¤â¤·¤¢¤ë¤Ê¤é) ½é´ü¥·¥Õ¥È¾õÂ֤ǻϤޤꡢ½é´ü¥·¥Õ¥È¾õÂ֤ǽª¤ï¤ë¡£
288 .\"O The format string is composed of zero or more directives: ordinary
289 .\"O characters (not
290 .\"O .BR % ),
291 .\"O which are copied unchanged to the output stream;
292 .\"O and conversion specifications, each of which results in fetching zero or
293 .\"O more subsequent arguments.
294 ¥Õ¥©¡¼¥Þ¥Ã¥ÈÍѤÎʸ»úÎó¤Ï 0 ¸Ä°Ê¾å¤ÎÌ¿Îá (directives) ¤Ë¤è¤Ã¤Æ¹½À®¤µ¤ì¤ë¡£
295 Ì¿Îá¤Ë¤Ï¡¢Ä̾ïʸ»ú¤ÈÊÑ´¹»ØÄê (conversion specifications) ¤¬¤¢¤ë¡£
296 Ä̾ïʸ»ú¤Ï
297 .B %
298 °Ê³°¤Îʸ»ú¤Ç¡¢½ÐÎÏ¥¹¥È¥ê¡¼¥à¤Ë¤½¤Î¤Þ¤Þ¥³¥Ô¡¼¤µ¤ì¤ë¡£
299 ÊÑ´¹»ØÄê¤Ï¡¢¤½¤ì¤¾¤ì¤¬ 0 ¸Ä°Ê¾å¤Î°ú¤­¿ô¤ò¼è¤ë¡£
300 .\"O Each conversion specification is introduced by
301 .\"O the character
302 .\"O .BR % ,
303 .\"O and ends with a
304 .\"O .IR "conversion specifier" .
305 ³ÆÊÑ´¹»ØÄê¤Ïʸ»ú
306 .B %
307 ¤Ç»Ï¤Þ¤ê¡¢
308 .I "ÊÑ´¹»ØÄê»Ò (conversion specifier)"
309 ¤Ç½ª¤ï¤ë¡£
310 .\"O In between there may be (in this order) zero or more
311 .\"O .IR flags ,
312 .\"O an optional minimum
313 .\"O .IR "field width" ,
314 .\"O an optional
315 .\"O .I precision
316 .\"O and an optional
317 .\"O .IR "length modifier" .
318 .B %
319 ¤ÈÊÑ´¹»ØÄê»Ò¤Î´Ö¤Ë¤Ï¡¢0 ¸Ä°Ê¾å¤Î
320 .I ¥Õ¥é¥° ¡¢
321 ºÇ¾®
322 .I ¥Õ¥£¡¼¥ë¥ÉÉý ¡¢
323 .I ÀºÅÙ ¡¢
324 .I Ä¹¤µ½¤¾þ»Ò
325 ¤ò (¤³¤Î½ç½ø¤Ç) ÃÖ¤¯¤³¤È¤¬¤Ç¤­¤ë¡£
326
327 .\"O The arguments must correspond properly (after type promotion) with the
328 .\"O conversion specifier.
329 .\"O By default, the arguments are used in the order
330 .\"O given, where each \(aq*\(aq and each conversion specifier asks for the next
331 .\"O argument (and it is an error if insufficiently many arguments are given).
332 °ú¤­¿ô¤Ï (·¿¤Î³Ê¾å¤²¤Î¸å¤Ï) ÊÑ´¹»ØÄê»Ò¤¬É½¤¹·¿¤ÈÀµ³Î¤ËÂбþ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
333 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢\(aq*\(aq ¤äÊÑ´¹»ØÄê»Ò¤¬½Ð¤Æ¤¯¤ëËè¤Ë¼¡¤Î°ú¤­¿ô¤òÍ׵ᤵ¤ì¡¢
334 °ú¤­¿ô¤Ï»ØÄꤵ¤ì¤¿½ç½ø¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤¯
335 (»ØÄꤵ¤ì¤¿°ú¤­¿ô¤Î¸Ä¿ô¤¬ÉÔ½½Ê¬¤Ê¤é¥¨¥é¡¼¤È¤Ê¤ë)¡£
336 .\"O One can also specify explicitly which argument is taken,
337 .\"O at each place where an argument is required, by writing "%m$" instead
338 .\"O of \(aq%\(aq and "*m$" instead of \(aq*\(aq,
339 .\"O where the decimal integer m denotes
340 .\"O the position in the argument list of the desired argument, indexed starting
341 .\"O from 1.
342 .\"O Thus,
343 .\"O .in +4n
344 .\"O .nf
345 .\"O
346 .\"O printf("%*d", width, num);
347 .\"O
348 .\"O .fi
349 .\"O .in
350 .\"O and
351 .\"O .in +4n
352 .\"O .nf
353 .\"O
354 .\"O printf("%2$*1$d", width, num);
355 .\"O
356 .\"O .fi
357 .\"O .in
358 ¤Þ¤¿¡¢°ú¤­¿ô¤¬É¬Íפʲսê¤Ç \(aq%\(aq ¤ÎÂå¤ï¤ê¤Ë "%m$"¡¢
359 \(aq*\(aq¤ÎÂå¤ï¤ê¤Ë "*m$" ¤È½ñ¤¯¤³¤È¤Ç¡¢
360 ÌÀ¼¨Åª¤Ë¤É¤Î°ú¤­¿ô¤ò»ÈÍѤ¹¤ë¤«¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¤ë¡£
361 ¤³¤³¤Ç 10¿Ê¤ÎÀ°¿ô m ¤Ï´õ˾¤Î°ú¤­¿ô¤Î°ú¤­¿ô¥ê¥¹¥È¤Ç¤Î°ÌÃÖ¤ò¼¨¤¹
362 (ºÇ½é¤Î°ú¤­¿ô¤ÎÈֹ椬 1 ¤Ç¤¢¤ë)¡£
363 ½¾¤Ã¤Æ¡¢°Ê²¼¤ÎÆó¤Ä¤ÏÅù²Á¤Ç¤¢¤ë¡£
364 .in +4n
365 .nf
366
367 printf("%*d", width, num);
368
369 printf("%2$*1$d", width, num);
370
371 .fi
372 .in
373 ¤ÏÅù²Á¤Ç¤¢¤ë¡£
374 .\"O are equivalent.
375 .\"O The second style allows repeated references to the
376 .\"O same argument.
377 .\"O The C99 standard does not include the style using \(aq$\(aq,
378 .\"O which comes from the Single Unix Specification.
379 .\"O If the style using
380 .\"O \(aq$\(aq is used, it must be used throughout for all conversions taking an
381 .\"O argument and all width and precision arguments, but it may be mixed
382 .\"O with "%%" formats which do not consume an argument.
383 .\"O There may be no
384 .\"O gaps in the numbers of arguments specified using \(aq$\(aq; for example, if
385 .\"O arguments 1 and 3 are specified, argument 2 must also be specified
386 .\"O somewhere in the format string.
387 ÆóÈÖÌܤνñ¤­Êý¤Ç¤ÏƱ¤¸°ú¤­¿ô¤ò·«¤êÊÖ¤·»²¾È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
388 C99 É¸½à¤Ë¤Ï¡¢ Single Unix Specification Í³Íè¤Î \(aq$\(aq ¤ò»È¤Ã¤¿½ñ¤­Êý¤Ï´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
389 \(aq$\(aq ¤ò»È¤Ã¤¿¥¹¥¿¥¤¥ë¤ò»È¤¦¤È¡¢°ú¤­¿ô¤ò¼è¤ëÊÑ´¹µÚ¤ÓÉý¤ÈÀºÅ٤ΰú¤­¿ô¤ò
390 Á´¤Æ¤³¤Î¥¹¥¿¥¤¥ë¤Ç»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤¬¡¢
391 °ú¤­¿ô¤ò¾ÃÈñ¤·¤Ê¤¤ "%%" ¥Õ¥©¡¼¥Þ¥Ã¥È¤Èº®¤¶¤Ã¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
392 \(aq$\(aq ¤Ç»ØÄꤵ¤ì¤ë°ú¤­¿ô¤ÎÈÖ¹æ¤Ë¶õ¤­¤¬¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
393 Î㤨¤Ð¡¢¤â¤·°ú¤­¿ô 1 ¤È 3 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢°ú¤­¿ô 2 ¤â¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Î¤É¤³¤«¤Ç
394 »ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
395
396 .\"O For some numeric conversion a radix character ("decimal point") or
397 .\"O thousands' grouping character is used.
398 .\"O The actual character used
399 .\"O depends on the
400 .\"O .B LC_NUMERIC
401 .\"O part of the locale.
402 .\"O The POSIX locale
403 .\"O uses \(aq.\(aq as radix character, and does not have a grouping character.
404 ¿ôÃÍÊÑ´¹¤Ë¤Ï¾®¿ôÅÀ¤ä 1000 Ã±°Ì¤Î¶èÀÚ¤êʸ»ú¤ò»È¤¦¤â¤Î¤â¤¢¤ë¡£
405 ¼ÂºÝ¤Ë¤É¤Îʸ»ú¤ò»È¤¦¤«¤Ï¥í¥±¡¼¥ë¤Î
406 .B LC_NUMERIC
407 ¤Ë¤è¤ë¡£
408 POSIX ¥í¥±¡¼¥ë¤Ç¤Ï¾®¿ôÅÀ¤Ë \(aq.\(aq ¤òÍѤ¤¡¢
409 ¶èÀÚ¤êʸ»ú¤Ï»È¤ï¤Ê¤¤¡£
410 .\"O Thus,
411 ½¾¤Ã¤Æ¡¢
412 .in +4n
413 .nf
414
415 printf("%\(aq.2f", 1234567.89);
416
417 .fi
418 .in
419 .\"O results in "1234567.89" in the POSIX locale, in "1234567,89" in the
420 .\"O nl_NL locale, and in "1.234.567,89" in the da_DK locale.
421 ¤Ï¡¢ POSIX ¥í¥±¡¼¥ë¤Ç¤Ï "1234567.89" ¡¢ nl_NL ¥í¥±¡¼¥ë¤Ç¤Ï "1234567,89"¡¢
422 da_DK ¥í¥±¡¼¥ë¤Ç¤Ï "1.234.567,89" ¤È¤Ê¤ë¡£
423 .\"O .SS "The flag characters"
424 .SS ¥Õ¥é¥°Ê¸»ú
425 .\"O The character % is followed by zero or more of the following flags:
426 % Ê¸»ú¤Î¸å¤í¤Ë¤Ï 0 ¸Ä°Ê¾å¤Î¥Õ¥é¥°Ê¸»ú¤¬Â³¤¯¡£
427 .TP
428 .\"O .B #
429 .\"O The value should be converted to an "alternate form".
430 .B #
431 ÃͤϡÖÊ̤ηÁ¼°¡×¤ËÊÑ´¹¤µ¤ì¤ë¡£
432 .\"O For
433 .\"O .B o
434 .\"O conversions, the first character of the output string is made zero
435 .\"O (by prefixing a 0 if it was not zero already).
436 .B o
437 ÊÑ´¹¤Î¾ì¹ç¡¢(ÀèƬʸ»ú¤¬ 0 ¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤ËÀèƬ¤Ë 0 ¤òÄɲ乤뤳¤È¤Ç)
438 ½ÐÎÏʸ»úÎó¤ÎºÇ½é¤Îʸ»ú¤ò 0 ¤Ë¤¹¤ë¡£
439 .\"O For
440 .\"O .B x
441 .\"O and
442 .\"O .B X
443 .\"O conversions, a nonzero result has the string "0x" (or "0X" for
444 .\"O .B X
445 .\"O conversions) prepended to it.
446 .B x
447 ¤È
448 .B X
449 ÊÑ´¹¤Î¾ì¹ç¡¢¿ôÃͤ¬ 0 ¤Ç¤Ê¤¤¤È¤­¤Ë¤Ïʸ»úÎó "0x"
450 .RB ( X
451 ÊÑ´¹¤Î¾ì¹ç¤Ë¤Ï "0X") ¤¬Á°¤ËÉÕÍ¿¤µ¤ì¤ë¡£
452 .\"O For
453 .\"O .BR a ,
454 .\"O .BR A ,
455 .\"O .BR e ,
456 .\"O .BR E ,
457 .\"O .BR f ,
458 .\"O .BR F ,
459 .\"O .BR g ,
460 .\"O and
461 .\"O .B G
462 .\"O conversions, the result will always contain a decimal point, even if no
463 .\"O digits follow it (normally, a decimal point appears in the results of those
464 .\"O conversions only if a digit follows).
465 .\"O For
466 .BR a ,
467 .BR A ,
468 .BR e ,
469 .BR E ,
470 .BR f ,
471 .BR F ,
472 .BR g ,
473 .B G
474 ÊÑ´¹¤Ç¤Ï¡¢ ¾®¿ôÅÀ¤Ë³¤¯¿ô»ú¤¬¤Ê¤¯¤Æ¤â¡¢
475 ½ÐÎϤˤϾï¤Ë¾®¿ôÅÀ¤¬´Þ¤Þ¤ì¤ë
476 (Ä̾ï¤Ï¡¢¾®¿ôÅÀ¤Î¸å¤Ë¿ô»ú¤¬Â³¤¯¾ì¹ç¤Ë¤Î¤ß¡¢
477 ¾®¿ôÅÀ¤¬É½¼¨¤µ¤ì¤ë)¡£
478 .\"O .B g
479 .\"O and
480 .\"O .B G
481 .\"O conversions, trailing zeros are not removed from the result as they would
482 .\"O otherwise be.
483 .B g
484 ¤È
485 .B G
486 ÊÑ´¹¤Î¾ì¹ç¡¢Â¾¤ÎÊÑ´¹¤È¤Ï°Û¤Ê¤ê¡¢ËöÈø¤Î¥¼¥í¤¬ÊÑ´¹·ë²Ì¤«¤éºï½ü¤µ¤ì¤Ê¤¤¡£
487 .\"O For other conversions, the result is undefined.
488 ¤½¤Î¾¤ÎÊÑ´¹¤Ç¤Ï¡¢·ë²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
489 .TP
490 .B \&0
491 .\"O The value should be zero padded.
492 .\"O For
493 .\"O .BR d ,
494 .\"O .BR i ,
495 .\"O .BR o ,
496 .\"O .BR u ,
497 .\"O .BR x ,
498 .\"O .BR X ,
499 .\"O .BR a ,
500 .\"O .BR A ,
501 .\"O .BR e ,
502 .\"O .BR E ,
503 .\"O .BR f ,
504 .\"O .BR F ,
505 .\"O .BR g ,
506 .\"O and
507 .\"O .B G
508 .\"O conversions, the converted value is padded on the left with zeros rather
509 .\"O than blanks.
510 Ãͤò¥¼¥í¤ÇËä¤á¤ë¡£
511 .BR d ,
512 .BR i ,
513 .BR o ,
514 .BR u ,
515 .BR x ,
516 .BR X ,
517 .BR a ,
518 .BR A ,
519 .BR e ,
520 .BR E ,
521 .BR f ,
522 .BR F ,
523 .BR g ,
524 .B G
525 ÊÑ´¹¤Ç¤Ï¡¢ÊÑ´¹¤·¤¿Ãͤκ¸Â¦¤ò¶õÇòʸ»ú¤ÎÂå¤ï¤ê¤Ë¥¼¥í¤ÇËä¤á¤ë¡£
526 .\"O If the
527 .\"O .B \&0
528 .\"O and
529 .\"O .B \-
530 .\"O flags both appear, the
531 .\"O .B \&0
532 .\"O flag is ignored.
533 .B \&0
534 ¤È
535 .B \-
536 ¤¬Î¾Êý¤È¤â»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
537 .B \&0
538 ¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡£
539 .\"O If a precision is given with a numeric conversion
540 .\"O .RB ( d ,
541 .\"O .BR i ,
542 .\"O .BR o ,
543 .\"O .BR u ,
544 .\"O .BR x ,
545 .\"O and
546 .\"O .BR X ),
547 .\"O the
548 .\"O .B \&0
549 .\"O flag is ignored.
550 ÀºÅÙ¤¬¿ôÃÍÊÑ´¹
551 .RB ( d ,
552 .BR i ,
553 .BR o ,
554 .BR u ,
555 .BR x ,
556 .BR X )
557 ¤ÈƱ»þ¤Ë»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
558 .B \&0
559 ¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡£
560 .\"O For other conversions, the behavior is undefined.
561 ¤½¤Î¾¤ÎÊÑ´¹¤Ç¤Ï¡¢Æ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
562 .TP
563 .B \-
564 .\"O The converted value is to be left adjusted on the field boundary.
565 .\"O (The default is right justification.)
566 .\"O Except for
567 .\"O .B n
568 .\"O conversions, the converted value is padded on the right with blanks, rather
569 .\"O than on the left with blanks or zeros.
570 .\"O A
571 ÊÑ´¹Ãͤò¥Õ¥£¡¼¥ë¥É¶­³¦¤Çº¸Â·¤¨¤Ë¤¹¤ë
572 (¥Ç¥Õ¥©¥ë¥È¤Ï±¦Â·¤¨¤Ç¤¢¤ë)¡£
573 .B n
574 ÊÑ´¹°Ê³°¤Ç¤Ï¡¢ÊÑ´¹¤µ¤ì¤¿ÃͤÏ
575 º¸Â¦¤Ç¤Ï¤Ê¤¯±¦Â¦¤ò¶õÇòʸ»ú¤ä¥¼¥í¤ÇËä¤á¤é¤ì¤ë¡£
576 .\"O .B \-
577 .\"O overrides a
578 .\"O .B \&0
579 .\"O if both are given.
580 .B \-
581 ¤È
582 .B \&0
583 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
584 .B \-
585 ¤¬Í¥À褵¤ì¤ë¡£
586 .TP
587 .\"O .B \(aq \(aq
588 .B ' '
589 .\"O (a space) A blank should be left before a positive number
590 .\"O (or empty string) produced by a signed conversion.
591 (1¸Ä¤ÎȾ³Ñ¥¹¥Ú¡¼¥¹)
592 Éä¹æÉÕ¤­ÊÑ´¹¤ÇÀ¸À®¤µ¤ì¤¿Àµ¤Î¿ô»ú¤ÎÁ°¤Ë¶õÇò (¤Þ¤¿¤Ï¶õʸ»úÎó) ¤¬ÃÖ¤«¤ì¤ë¡£
593 .TP
594 .\"O .B +
595 .\"O A sign (+ or \-) should always be placed before a number produced by a signed
596 .\"O conversion.
597 .\"O By default a sign is used only for negative numbers.
598 .\"O A
599 .\"O .B +
600 .\"O overrides a space if both are used.
601 .B +
602 Éä¹æÉÕ¤­ÊÑ´¹¤Ë¤è¤Ã¤Æ½ÐÎϤµ¤ì¤ë¿ô»ú¤ÎÁ°¤Ë¡¢¾ï¤ËÉä¹æ (+ ¤« \-) ¤¬ÃÖ¤«¤ì¤ë¡£
603 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢Éä¹æ¤ÏÉé¤Î¿ô»ú¤Î¾ì¹ç¤Î¤ßÉÕÍ¿¤µ¤ì¤ë¡£
604 .B +
605 ¤ÈȾ³Ñ¥¹¥Ú¡¼¥¹¤Î
606 ξÊý¤¬»È¤ï¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
607 .B +
608 ¤¬Í¥À褵¤ì¤ë¡£
609 .PP
610 .\"O The five flag characters above are defined in the C standard.
611 .\"O The SUSv2 specifies one further flag character.
612 ¾åµ­¤Î 5 ¤Ä¤Î¥Õ¥é¥°¤Ï C É¸½à¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
613 SUSv2 ¤Ç¤Ï¡¢¤µ¤é¤Ë¤â¤¦°ì¤Ä¥Õ¥é¥°Ê¸»ú¤¬µ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
614 .TP
615 .B \(aq
616 .\"O For decimal conversion
617 .\"O .RB ( i ,
618 .\"O .BR d ,
619 .\"O .BR u ,
620 .\"O .BR f ,
621 .\"O .BR F ,
622 .\"O .BR g ,
623 .\"O .BR G )
624 .\"O the output is to be grouped with thousands' grouping characters
625 .\"O if the locale information indicates any.
626 .\"O Note that many versions of
627 .\"O .BR gcc (1)
628 .\"O cannot parse this option and will issue a warning.
629 .\"O SUSv2 does not
630 .\"O include %\(aqF.
631 10¿Ê¿ôÊÑ´¹
632 .RB ( i ,
633 .BR d ,
634 .BR u ,
635 .BR f ,
636 .BR F ,
637 .BR g ,
638 .BR G )
639 ¤Ë¤ª¤¤¤Æ¡¢¥í¥±¡¼¥ë¾ðÊó¤Ë»ØÄ꤬¤¢¤ì¤Ð 1000 Ã±°Ì¤Î¶èÀÚ¤êʸ»ú¤ò½ÐÎϤ¹¤ë¡£
640 .BR gcc (1)
641 ¤Î¿¤¯¤Î¥Ð¡¼¥¸¥ç¥ó¤Ï¡¢¤³¤Î¥ª¥×¥·¥ç¥ó¤ò²ò¼á¤¹¤ë¤³¤È¤¬¤Ç¤­¤º¡¢
642 ·Ù¹ð¤ò½ÐÎϤ¹¤ë¤³¤È¤ËÃí°Õ¤»¤è¡£
643 %\(aqF ¤Ï SUSv2 ¤Ë¤Ï´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
644 .PP
645 .\"O glibc 2.2 adds one further flag character.
646 glibc 2.2 ¤Ç¤Ï¡¢¤µ¤é¤Ë°ì¤Ä¥Õ¥é¥°Ê¸»ú¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
647 .TP
648 .B I
649 .\"O For decimal integer conversion
650 .\"O .RB ( i ,
651 .\"O .BR d ,
652 .\"O .BR u )
653 .\"O the output uses the locale's alternative output digits, if any.
654 .\"O For example, since glibc 2.2.3 this will give Arabic-Indic digits
655 .\"O in the Persian ("fa_IR") locale.
656 .\"O .\" outdigits keyword in locale file
657 10¿ÊÀ°¿ôÊÑ´¹
658 .RB ( i ,
659 .BR d ,
660 .BR u )
661 ¤Ë¤ª¤¤¤Æ¡¢¥í¥±¡¼¥ë¤ÎÂåÂؽÐÎÏ¿ô»ú¤¬¤¢¤ì¤Ð¡¢¤½¤ì¤òÍѤ¤¤Æ½ÐÎϤ¹¤ë¡£
662 Î㤨¤Ð¡¢ glibc 2.2.3 °Ê¹ß¤Ç¤Ï¡¢¥Ú¥ë¥·¥¢ ("fa_IR") ¥í¥±¡¼¥ë¤Ç
663 ¥¢¥é¥Ó¥¢¿ô»ú (Arabic-Indic digits) ¤ò½ÐÎϤǤ­¤ë¡£
664 .\" ¥í¥±¡¼¥ë¥Õ¥¡¥¤¥ë¤Ë¤Ï outdigits ¤È¤¤¤¦¥­¡¼¥ï¡¼¥É¤¬¤¢¤ë¡£
665 .\"O .SS "The field width"
666 .SS ¥Õ¥£¡¼¥ë¥ÉÉý
667 .\"O An optional decimal digit string (with nonzero first digit) specifying
668 .\"O a minimum field width.
669 .\"O If the converted value has fewer characters
670 .\"O than the field width, it will be padded with spaces on the left
671 .\"O (or right, if the left-adjustment flag has been given).
672 ºÇ¾®¤Î¥Õ¥£¡¼¥ë¥ÉÉý¤ò»ØÄꤹ¤ë 10¿Ê¿ô¤Î¿ôÃÍʸ»úÎó (ʸ»úÎó¤ÎºÇ½é¤Îʸ»ú¤Ï
673 ¥¼¥í°Ê³°)¡£ËܹàÌܤϥª¥×¥·¥ç¥ó¤Ç¤¢¤ë¡£
674 ÊÑ´¹¤µ¤ì¤¿ÃͤÎʸ»ú¿ô¤¬¥Õ¥£¡¼¥ë¥ÉŤè¤ê¤â¾¯¤Ê¤¤¾ì¹ç¡¢
675 ¥Õ¥£¡¼¥ë¥É¤Îº¸Â¦¤ò¥¹¥Ú¡¼¥¹¤ÇËä¤á¤ë
676 (º¸Â·¤¨¤Î¥Õ¥é¥°¤¬¤¢¤ë¾ì¹ç¤Ï±¦Â¦¤òËä¤á¤ë)¡£
677 .\"O Instead of a decimal digit string one may write "*" or "*m$"
678 .\"O (for some decimal integer \fIm\fP) to specify that the field width
679 .\"O is given in the next argument, or in the \fIm\fP-th argument, respectively,
680 .\"O which must be of type
681 .\"O .IR int .
682 10¿Ê¿ô¤Îʸ»úÎó¤ÎÂå¤ï¤ê¤Ë "*" ¤ä "*m$" (\fIm\fP ¤Ï 10¿ÊÀ°¿ô) ¤ò½ñ¤¯¤³¤È¤â¤Ç¤­¤ë¡£
683 "*" ¤È "*m$" ¤Ï¤½¤ì¤¾¤ì¡¢¼¡¤Î°ú¤­¿ô¤È \fIm\fP ÈÖÌܤΰú¤­¿ô¤ò¥Õ¥£¡¼¥ë¥ÉÉý¤È¤·¤Æ
684 »È¤¦¤³¤È¤ò»ØÄꤹ¤ë (¤³¤ì¤é¤Î°ú¤­¿ô¤Ï
685 .I int
686 ·¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£
687 .\"O A negative field width is taken as a \(aq\-\(aq flag followed by a
688 .\"O positive field width.
689 ¥Õ¥£¡¼¥ë¥ÉÉý¤ËÉé¤Î¿ô¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
690 \(aq\-\(aq ¥Õ¥é¥°¤ÈÀµ¤Î¿ô¤Î¥Õ¥£¡¼¥ë¥ÉÉý¤È¤·¤Æ°·¤ï¤ì¤ë¡£
691 .\"O In no case does a nonexistent or small field width cause truncation of a
692 .\"O field; if the result of a conversion is wider than the field width, the
693 .\"O field is expanded to contain the conversion result.
694 ¥Õ¥£¡¼¥ë¥ÉÉý¤¬¾®¤µ¤«¤Ã¤¿¤ê»ØÄ꤬¤Ê¤«¤Ã¤¿¤ê¤·¤Æ¤â¡¢¥Õ¥£¡¼¥ë¥É¤¬ÀÚ¤êµÍ¤á¤é¤ì¤ë
695 ¤³¤È¤Ï¤Ê¤¤¡£¤â¤·ÊÑ´¹·ë²Ì¤¬¥Õ¥£¡¼¥ë¥ÉÉý¤è¤ê¤â¹­¤«¤Ã¤¿¾ì¹ç¡¢
696 ¥Õ¥£¡¼¥ë¥É¤ÏÊÑ´¹·ë²Ì¤¬Æþ¤ëÉý¤Ë¹­¤²¤é¤ì¤ë¡£
697 .\"O .SS "The precision"
698 .SS ÀºÅÙ
699 .\"O An optional precision, in the form of a period (\(aq.\(aq)  followed by an
700 .\"O optional decimal digit string.
701 ¥ª¥×¥·¥ç¥ó¤Ç¤¢¤ëÀºÅ٤ϡ¢¥Ô¥ê¥ª¥É (\(aq.\(aq) ¤È¤½¤ì¤Ë³¤¯10¿Ê¿ô¤È¤¤¤¦
702 ·Á¼°¤Ç»ØÄꤹ¤ë (10¿Ê¿ô¤Ï¥ª¥×¥·¥ç¥ó) ¡£
703 .\"O Instead of a decimal digit string one may write "*" or "*m$"
704 .\"O (for some decimal integer m) to specify that the precision
705 .\"O is given in the next argument, or in the m-th argument, respectively,
706 .\"O which must be of type
707 .\"O .IR int .
708 10¿Ê¿ô¤Îʸ»úÎó¤ÎÂå¤ï¤ê¤Ë "*" ¤ä "*m$" (m ¤Ï 10 ¿ÊÀ°¿ô)¤ò½ñ¤¯¤³¤È¤â¤Ç¤­¤ë¡£
709 "*" ¤È "*m$" ¤Ï¤½¤ì¤¾¤ì¡¢¼¡¤Î°ú¤­¿ô¤È m ÈÖÌܤΰú¤­¿ô¤òÀºÅ٤Ȥ·¤Æ
710 »È¤¦¤³¤È¤ò»ØÄꤹ¤ë (¤³¤ì¤é¤Î°ú¤­¿ô¤Ï
711 .I int
712 ·¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£
713 .\"O If the precision is given as just \(aq.\(aq, or the precision is negative,
714 .\"O the precision is taken to be zero.
715 ÀºÅ٤Ȥ·¤Æ \(aq.\(aq ¤À¤±¤¬»ØÄꤵ¤ì¤¿¤ê¡¢ÀºÅÙ¤¬Éé¤Î¿ô¤À¤Ã¤¿¾ì¹ç¡¢
716 ÀºÅ٤ϥ¼¥í¤È¤ß¤Ê¤µ¤ì¤ë¡£
717 .\"O This gives the minimum number of digits to appear for
718 .\"O .BR d ,
719 .\"O .BR i ,
720 .\"O .BR o ,
721 .\"O .BR u ,
722 .\"O .BR x ,
723 .\"O and
724 .\"O .B X
725 .\"O conversions, the number of digits to appear after the radix character for
726 .\"O .BR a ,
727 .\"O .BR A ,
728 .\"O .BR e ,
729 .\"O .BR E ,
730 .\"O .BR f ,
731 .\"O and
732 .\"O .B F
733 .\"O conversions, the maximum number of significant digits for
734 .\"O .B g
735 .\"O and
736 .\"O .B G
737 .\"O conversions, or the maximum number of characters to be printed from a
738 .\"O string for
739 .\"O .B s
740 .\"O and
741 .\"O .B S
742 .\"O conversions.
743 .BR d ,
744 .BR i ,
745 .BR o ,
746 .BR u ,
747 .BR x ,
748 .B X
749 ÊÑ´¹¤Ç¤Ï¡¢É½¼¨¤µ¤ì¤ëºÇ¾®¤Î·å¿ô¤ò»ØÄꤹ¤ë¡£
750 .BR a ,
751 .BR A ,
752 .BR e ,
753 .BR E ,
754 .BR f ,
755 .B F
756 ÊÑ´¹¤Ç¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ëɽ¼¨¤µ¤ì¤ë¿ô»ú¤Î·å¿ô¤ò»ØÄꤹ¤ë¡£
757 .B g
758 ¤È
759 .B G
760 ÊÑ´¹¤Ç¤Ï¡¢Í­¸ú¿ô»ú¤ÎºÇÂç·å¿ô¤ò»ØÄꤹ¤ë¡£
761 .B s
762 ¤È
763 .B S
764 ÊÑ´¹¤Ç¤Ï¡¢Ê¸»úÎ󤫤é½ÐÎϤµ¤ì¤ëºÇÂçʸ»ú¿ô¤ò»ØÄꤹ¤ë¡£
765 .\"O .SS "The length modifier"
766 .SS Ä¹¤µ½¤¾þ»Ò
767 .\"O Here, "integer conversion" stands for
768 .\"O .BR d ,
769 .\"O .BR i ,
770 .\"O .BR o ,
771 .\"O .BR u ,
772 .\"O .BR x ,
773 .\"O or
774 .\"O .B X
775 .\"O conversion.
776 ¡ÖÀ°¿ôÊÑ´¹¡×¤È¤Ï¡¢
777 .BR d ,
778 .BR i ,
779 .BR o ,
780 .BR u ,
781 .BR x ,
782 .B X
783 ÊÑ´¹¤Î¤³¤È¤Ç¤¢¤ë¡£
784 .TP
785 .B hh
786 .\"O A following integer conversion corresponds to a
787 .\"O .I signed char
788 .\"O or
789 .\"O .I unsigned char
790 .\"O argument, or a following
791 .\"O .B n
792 .\"O conversion corresponds to a pointer to a
793 .\"O .I signed char
794 .\"O argument.
795 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
796 .I signed char
797 ¤«
798 .I unsigned char
799 ¤Ç¡¢
800 .B n
801 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
802 .I signed char
803 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
804 .TP
805 .B h
806 .\"O A following integer conversion corresponds to a
807 .\"O .I short int
808 .\"O or
809 .\"O .I unsigned short int
810 .\"O argument, or a following
811 .\"O .B n
812 .\"O conversion corresponds to a pointer to a
813 .\"O .I short int
814 .\"O argument.
815 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
816 .I short int
817 ¤«
818 .I unsigned short int
819 ¤Ç¡¢
820 .B n
821 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
822 .I short int
823 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
824 .TP
825 .\"O .B l
826 .\"O (ell) A following integer conversion corresponds to a
827 .\"O .I long int
828 .\"O or
829 .\"O .I unsigned long int
830 .\"O argument, or a following
831 .\"O .B n
832 .\"O conversion corresponds to a pointer to a
833 .\"O .I long long int
834 .\"O argument, or a following
835 .\"O .B c
836 .\"O conversion corresponds to a
837 .\"O .I wint_t
838 .\"O argument, or a following
839 .\"O .B s
840 .\"O conversion corresponds to a pointer to
841 .\"O .I wchar_t
842 .\"O argument.
843 .BR l " (¥¨¥ë)"
844 ³ÆÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬¡¢
845 À°¿ôÊÑ´¹¤Ç¤Ï
846 .IR "long int" ¤«
847 .IR "unsigned long int" ¡¢
848 .B n
849 ÊÑ´¹¤Ç¤Ï
850 .I long long int
851 ¤Ø¤Î¥Ý¥¤¥ó¥¿¡¢
852 .B c
853 ÊÑ´¹¤Ç¤Ï
854 .IR wint_t ¡¢
855 .B s
856 ÊÑ´¹¤Ç¤Ï
857 .I wchar_t
858 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
859
860 .TP
861 .\"O .B ll
862 .\"O (ell-ell).
863 .\"O A following integer conversion corresponds to a
864 .\"O .I long long int
865 .\"O or
866 .\"O .I unsigned long long int
867 .\"O argument, or a following
868 .\"O .B n
869 .\"O conversion corresponds to a pointer to a
870 .\"O .I long int
871 .\"O argument.
872 .BR ll " (¥¨¥ë¥¨¥ë)"
873 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
874 .I long long int
875 ¤«
876 .I unsigned long long int
877 ¤Ç¡¢
878 .B n
879 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
880 .I long int
881 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
882 .TP
883 .B L
884 .\"O A following
885 .\"O .BR a ,
886 .\"O .BR A ,
887 .\"O .BR e ,
888 .\"O .BR E ,
889 .\"O .BR f ,
890 .\"O .BR F ,
891 .\"O .BR g ,
892 .\"O or
893 .\"O .B G
894 .\"O conversion corresponds to a
895 .\"O .I long double
896 .\"O argument.
897 .BR a ,
898 .BR A ,
899 .BR e ,
900 .BR E ,
901 .BR f ,
902 .BR F ,
903 .BR g ,
904 .B G
905 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
906 .I long double
907 ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
908 .\"O (C99 allows %LF, but SUSv2 does not.)
909 (C99 ¤Ç¤Ï %LF ¤ò»È¤¦¤³¤È¤òǧ¤á¤Æ¤¤¤ë¤¬¡¢SUSv2 ¤Ç¤Ïǧ¤á¤é¤ì¤Æ¤¤¤Ê¤¤¡£)
910 .TP
911 .B q
912 .\"O ("quad". 4.4BSD and Linux libc5 only.
913 .\"O Don't use.)
914 .\"O This is a synonym for
915 .\"O .BR ll .
916 ("quad"¡£ 4.4BSD ¤È Linux libc5 ¤Î¤ßÍ­¸ú¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£)
917 .B ll
918 ¤ÈƱ¤¸°ÕÌ£¤Ç¤¢¤ë¡£
919 .TP
920 .B j
921 .\"O A following integer conversion corresponds to an
922 .\"O .I intmax_t
923 .\"O or
924 .\"O .I uintmax_t
925 .\"O argument.
926 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
927 .I intmax_t
928 ¤«
929 .I uintmax_t
930 ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
931 .TP
932 .B z
933 .\"O A following integer conversion corresponds to a
934 .\"O .I size_t
935 .\"O or
936 .\"O .I ssize_t
937 .\"O argument.
938 .\"O (Linux libc5 has
939 .\"O .B Z
940 .\"O with this meaning.
941 .\"O Don't use it.)
942 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
943 .I size_t
944 ¤«
945 .I ssize_t
946 ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
947 (Linux libc5 ¤Ç¤Ï¡¢¤³¤ì¤ò»ØÄꤹ¤ë¤Î¤Ë
948 .B Z
949 ¤òÍѤ¤¤ë¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£)
950 .TP
951 .B t
952 .\"O A following integer conversion corresponds to a
953 .\"O .I ptrdiff_t
954 .\"O argument.
955 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤­¿ô¤¬
956 .I ptrdiff_t
957 ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
958 .PP
959 .\"O The SUSv2 only knows about the length modifiers
960 .\"O .B h
961 .\"O (in
962 .\"O .BR hd ,
963 .\"O .BR hi ,
964 .\"O .BR ho ,
965 .\"O .BR hx ,
966 .\"O .BR hX ,
967 .\"O .BR hn )
968 .\"O and
969 .\"O .B l
970 .\"O (in
971 .\"O .BR ld ,
972 .\"O .BR li ,
973 .\"O .BR lo ,
974 .\"O .BR lx ,
975 .\"O .BR lX ,
976 .\"O .BR ln ,
977 .\"O .BR lc ,
978 .\"O .BR ls )
979 .\"O and
980 .\"O .B L
981 .\"O (in
982 .\"O .BR Le ,
983 .\"O .BR LE ,
984 .\"O .BR Lf ,
985 .\"O .BR Lg ,
986 .\"O .BR LG ).
987 SUSv2 ¤ÇŤµ½¤¾þ»Ò¤È¤·¤Æ»ÈÍѤǤ­¤ë¤Î¤Ï¡¢
988 .B h
989 .RB ( hd ,
990 .BR hi ,
991 .BR ho ,
992 .BR hx ,
993 .BR hX ,
994 .BR hn ),
995 .B l
996 .RB ( ld ,
997 .BR li ,
998 .BR lo ,
999 .BR lx ,
1000 .BR lX ,
1001 .BR ln ,
1002 .BR lc ,
1003 .BR ls ),
1004 .B L
1005 .RB ( Le ,
1006 .BR LE ,
1007 .BR Lf ,
1008 .BR Lg ,
1009 .BR LG )
1010 ¤À¤±¤Ç¤¢¤ë¡£
1011 .\"O .SS "The conversion specifier"
1012 .SS ÊÑ´¹»ØÄê»Ò
1013 .\"O A character that specifies the type of conversion to be applied.
1014 ŬÍѤµ¤ì¤ëÊÑ´¹¤Î·¿¤ò»ØÄꤹ¤ëʸ»ú¡£
1015 .PP
1016 .\"O The conversion specifiers and their meanings are:
1017 ÊÑ´¹»ØÄê»Ò¤È¤½¤Î°ÕÌ£¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1018 .TP
1019 .BR d ", " i
1020 .\"O The
1021 .\"O .I int
1022 .\"O argument is converted to signed decimal notation.
1023 .I int
1024 °ú¤­¿ô¤òÉä¹æÉÕ¤­ 10 ¿Êɽµ­¤ËÊÑ´¹¤¹¤ë¡£
1025 .\"O The precision, if any, gives the minimum number of digits
1026 .\"O that must appear; if the converted value requires fewer digits, it is
1027 .\"O padded on the left with zeros.
1028 .\"O The default precision is 1.
1029 ÀºÅÙ»ØÄ꤬¤¢¤ì¤Ð¡¢ÀºÅ٤ǻØÄꤷ¤¿·å¿ô¤Ïɬ¤º½ÐÎϤµ¤ì¤ë¡£ÊÑ´¹¸å¤ÎÃͤ¬
1030 »ØÄꤵ¤ì¤¿·å¿ô¤Ë­¤ê¤Ê¤¤¾ì¹ç¤Ï¡¢º¸Â¦¤¬ 0 ¤ÇËä¤á¤é¤ì¤ë¡£
1031 ¥Ç¥Õ¥©¥ë¥È¤ÎÀºÅ٤Ϡ1 ¤Ç¤¢¤ë¡£
1032 .\"O When 0 is printed with an explicit precision 0, the output is empty.
1033 0 ¤òɽ¼¨¤·¤è¤¦¤È¤·¤¿»þ¤Ë¡¢ÌÀ¼¨Åª¤ËÀºÅ٤Ȥ·¤Æ 0 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤È¡¢
1034 ½ÐÎϤ϶õʸ»úÎó¤È¤Ê¤ë¡£
1035 .TP
1036 .BR o ", " u ", " x ", " X
1037 .\"O The
1038 .\"O .I "unsigned int"
1039 .\"O argument is converted to unsigned octal
1040 .\"O .RB ( o ),
1041 .\"O unsigned decimal
1042 .\"O .RB ( u ),
1043 .\"O or unsigned hexadecimal
1044 .\"O .RB ( x
1045 .\"O and
1046 .\"O .BR X )
1047 .\"O notation.
1048 .I "unsigned int"
1049 °ú¤­¿ô¤ò¡¢
1050 Éä¹æ¤Ê¤·8¿Ê¿ô
1051 .RB ( o ),
1052 Éä¹æ¤Ê¤·10¿Ê¿ô
1053 .RB ( u ),
1054 Éä¹æ¤Ê¤·16¿Ê¿ô
1055 .RB ( x
1056 ¤È
1057 .BR X )
1058 ¤ËÊÑ´¹¤¹¤ë¡£
1059 .\"O The letters
1060 .\"O .B abcdef
1061 .\"O are used for
1062 .\"O .B x
1063 .\"O conversions; the letters
1064 .\"O .B ABCDEF
1065 .\"O are used for
1066 .\"O .B X
1067 .\"O conversions.
1068 .B x
1069 ÊÑ´¹¤Ç¤Ï
1070 .B abcdef
1071 ¤¬»ÈÍѤµ¤ì¡¢
1072 .B X
1073 ÊÑ´¹¤Ç¤Ï
1074 .B ABCDEF
1075 ¤¬»ÈÍѤµ¤ì¤ë¡£
1076 .\"O The precision, if any, gives the minimum number of digits
1077 .\"O that must appear; if the converted value requires fewer digits, it is
1078 .\"O padded on the left with zeros.
1079 ÀºÅÙ»ØÄ꤬¤¢¤ì¤Ð¡¢ÀºÅ٤ǻØÄꤷ¤¿·å¿ô¤Ïɬ¤º½ÐÎϤµ¤ì¤ë¡£ÊÑ´¹¸å¤ÎÃͤ¬
1080 »ØÄꤵ¤ì¤¿·å¿ô¤Ë­¤ê¤Ê¤¤¾ì¹ç¤Ï¡¢º¸Â¦¤¬ 0 ¤ÇËä¤á¤é¤ì¤ë¡£
1081 .TP
1082 .BR e ", " E
1083 .\"O The
1084 .\"O .I double
1085 .\"O argument is rounded and converted in the style
1086 .\"O .if \w'\*(Pm'=0 .ds Pm \(+-
1087 .\"O .RB [\-]d \&. ddd e \\*(Pmdd
1088 .\"O where there is one digit before the decimal-point character and the number
1089 .\"O of digits after it is equal to the precision; if the precision is missing,
1090 .\"O it is taken as 6; if the precision is zero, no decimal-point character
1091 .\"O appears.
1092 .\"O An
1093 .I double
1094 °ú¤­¿ô¤ò´Ý¤á¤Æ
1095 .if \w'\*(Pm'=0 .ds Pm \(+-
1096 .RB [\-]d \&. ddd e \\*(Pmdd
1097 ¤Î·Á¤ËÊÑ´¹¤¹¤ë¡£
1098 ¾®¿ôÅÀ¤ÎÁ°¤Ë¤Ï°ì·å¤Î¿ô»ú¤¬¤¢¤ê¡¢¾®¿ôÅÀ°Ê²¼¤Î·å¿ô¤ÏÀºÅ٤ǻØÄꤵ¤ì¤¿
1099 ·å¿ô¤Ë¤Ê¤ë¡£ÀºÅ٤ϻØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç 6 ¤È¤ß¤Ê¤µ¤ì¤ë¡£
1100 ÀºÅÙ¤¬ 0 ¤Î¾ì¹ç¤Ë¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ïɽ¼¨¤µ¤ì¤Ê¤¤¡£
1101 .\"O .B E
1102 .\"O conversion uses the letter
1103 .\"O .B E
1104 .\"O (rather than
1105 .\"O .BR e )
1106 .\"O to introduce the exponent.
1107 .B E
1108 ÊÑ´¹¤Ç¤Ï¡¢»Ø¿ô¤òɽ¸½¤¹¤ë¤È¤­¤Ë
1109 .RB ( e
1110 ¤Ç¤Ï¤Ê¤¯)
1111 .B E
1112 ¤¬»È¤ï¤ì¤ë¡£
1113 .\"O The exponent always contains at least two
1114 .\"O digits; if the value is zero, the exponent is 00.
1115 »Ø¿ôÉôʬ¤Ï¾¯¤Ê¤¯¤È¤â 2·åɽ¼¨¤µ¤ì¤ë¡£
1116 ¤Ä¤Þ¤ê¡¢»Ø¿ô¤ÎÃͤ¬ 0 ¤Î¾ì¹ç¤Ë¤Ï¡¢00 ¤Èɽ¼¨¤µ¤ì¤ë¡£
1117 .TP
1118 .BR f ", " F
1119 .\"O The
1120 .\"O .I double
1121 .\"O argument is rounded and converted to decimal notation in the style
1122 .\"O .RB [\-]ddd \&. ddd,
1123 .\"O where the number of digits after the decimal-point character is equal to
1124 .\"O the precision specification.
1125 .I double
1126 °ú¤­¿ô¤ò´Ý¤á¤Æ
1127 .RB [\-]ddd \&. ddd
1128 ¤Î·Á¤Î10¿Êɽ¸½¤ËÊÑ´¹¤¹¤ë¡£
1129 ¾®¿ôÅÀ¤Î¸å¤Î·å¿ô¤Ï¡¢ÀºÅ٤ǻØÄꤵ¤ì¤¿ÃͤȤʤ롣
1130 .\"O If the precision is missing, it is taken as
1131 .\"O 6; if the precision is explicitly zero, no decimal-point character appears.
1132 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï 6 ¤È¤·¤Æ°·¤ï¤ì¤ë¡£
1133 ÀºÅ٤Ȥ·¤ÆÌÀ¼¨Åª¤Ë 0 ¤¬»ØÄꤵ¤ì¤¿¤È¤­¤Ë¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ïɽ¼¨¤µ¤ì¤Ê¤¤¡£
1134 .\"O If a decimal point appears, at least one digit appears before it.
1135 ¾®¿ôÅÀ¤òɽ¼¨¤¹¤ëºÝ¤Ë¤Ï¡¢¾®¿ôÅÀ¤ÎÁ°¤Ë¾¯¤Ê¤¯¤È¤â°ì·å¤Ï¿ô»ú¤¬É½¼¨¤µ¤ì¤ë¡£
1136
1137 .\"O (The SUSv2 does not know about
1138 .\"O .B F
1139 .\"O and says that character string representations for infinity and NaN
1140 .\"O may be made available.
1141 .\"O The C99 standard specifies "[\-]inf" or "[\-]infinity"
1142 .\"O for infinity, and a string starting with "nan" for NaN, in the case of
1143 .\"O .B f
1144 .\"O conversion, and "[\-]INF" or "[\-]INFINITY" or "NAN*" in the case of
1145 .\"O .B F
1146 .\"O conversion.)
1147 (SUSv2 ¤Ç¤Ï¡¢
1148 .B F
1149 ¤Ïµ¬Äꤵ¤ì¤Æ¤ª¤é¤º¡¢Ìµ¸Â¤ä NaN ¤Ë´Ø¤¹¤ëʸ»úÎóɽ¸½¤ò
1150 ¹Ô¤Ã¤Æ¤â¤è¤¤¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
1151  C99 É¸½à¤Ç¤Ï¡¢
1152 .B f
1153 ÊÑ´¹¤Ç¤Ï¡¢Ìµ¸Â¤Ï "[\-]inf" ¤« "[\-]infinity" ¤Èɽ¼¨¤·¡¢
1154 NaN ¤Ïʸ»úÎó¤ÎÀèƬ¤Ë `nan' ¤ò¤Ä¤±¤Æɽ¼¨¤¹¤ë¤è¤¦¤Ëµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
1155 .B F
1156 ÊÑ´¹¤Î¾ì¹ç¤Ï "[\-]INF", "[\-]INFINITY", "NAN*" ¤Èɽ¼¨¤µ¤ì¤ë¡£)
1157 .TP
1158 .BR g ", " G
1159 .\"O The
1160 .\"O .I double
1161 .\"O argument is converted in style
1162 .\"O .B f
1163 .\"O or
1164 .\"O .B e
1165 .\"O (or
1166 .\"O .B F
1167 .\"O or
1168 .\"O .B E
1169 .\"O for
1170 .\"O .B G
1171 .\"O conversions).
1172 .I double
1173 °ú¤­¿ô¤ò
1174 .B f
1175 ¤«
1176 .B e
1177 .RB ( G
1178 ÊÑ´¹¤Î¾ì¹ç¤Ï
1179 .B F
1180 ¤«
1181 .BR E )
1182 ¤Î·Á¼°¤ËÊÑ´¹¤¹¤ë¡£
1183 .\"O The precision specifies the number of significant digits.
1184 ÀºÅÙ¤Ïɽ¼¨¤¹¤ë·å¿ô¤ò»ØÄꤹ¤ë¡£
1185 .\"O If the precision is missing, 6 digits are given; if the precision is zero,
1186 .\"O it is treated as 1.
1187 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Ê¤¤¾ì¹ç¤Ï¡¢6·å¤È¤ß¤Ê¤µ¤ì¤ë¡£
1188 ÀºÅÙ¤¬ 0 ¤Î¾ì¹ç¤Ï¡¢1·å¤È¤ß¤Ê¤µ¤ì¤ë¡£
1189 .\"O Style
1190 .\"O .B e
1191 .\"O is used if the exponent from its conversion is less than \-4 or greater
1192 .\"O than or equal to the precision.
1193 ÊÑ´¹¤µ¤ì¤ëÃͤλؿô¤¬¡¢ \-4 ¤è¤ê¾®¤µ¤¤¤«¡¢ÀºÅٰʾå¤Î¾ì¹ç¤Ë¡¢
1194 .B e
1195 ·Á¼°¤¬»ÈÍѤµ¤ì¤ë¡£
1196 .\"O Trailing zeros are removed from the
1197 .\"O fractional part of the result; a decimal point appears only if it is
1198 .\"O followed by at least one digit.
1199 ÊÑ´¹¤µ¤ì¤¿·ë²Ì¤Î¾®¿ôÉôʬ¤ÎËöÈø¤Î 0 ¤Ïºï½ü¤µ¤ì¤ë¡£¾®¿ôÅÀ¤¬É½¼¨¤µ¤ì¤ë¤Î¤Ï¡¢
1200 ¾®¿ôÅÀ°Ê²¼¤Ë¿ô»ú¤¬¾¯¤Ê¤¯¤È¤â°ì¤Ä¤¢¤ë¾ì¹ç¤Ë¤À¤±¤Ç¤¢¤ë¡£
1201 .TP
1202 .BR a ", " A
1203 .\"O (C99; not in SUSv2) For
1204 .\"O .B a
1205 .\"O conversion, the
1206 .\"O .I double
1207 .\"O argument is converted to hexadecimal notation (using the letters abcdef)
1208 .\"O in the style
1209 .\"O .RB [\-] 0x h \&. hhhh p \\*(Pmd;
1210 .\"O for
1211 .\"O .B A
1212 .\"O conversion the prefix
1213 .\"O .BR 0X ,
1214 .\"O the letters ABCDEF, and the exponent separator
1215 .\"O .B P
1216 .\"O is used.
1217 (C99 ¤Ë¤Ï¤¢¤ë¤¬ SUSv2 ¤Ë¤Ï¤Ê¤¤)
1218 .B a
1219 ÊÑ´¹¤Ç¤Ï¡¢
1220 .I double
1221 °ú¤­¿ô¤ò (abcdef ¤Îʸ»ú¤ò»È¤Ã¤Æ)
1222 .RB [\-] 0x h \&. hhhh p \\*(Pmd;
1223 ·Á¼°¤Î 16 ¿Êɽµ­¤ËÊÑ´¹¤¹¤ë¡£
1224 .B A
1225 ÊÑ´¹¤Ç¤Ï¡¢Á°ÃÖʸ»úÎó
1226 .BR 0X ,
1227 ʸ»ú ABCDEF, »Ø¿ôʸ»ú
1228 .B P
1229 ¤òÍѤ¤¤ë¡£
1230 .\"O There is one hexadecimal digit before the decimal point,
1231 .\"O and the number of digits after it is equal to the precision.
1232 ¾®¿ôÅÀ¤ÎÁ°¤Ë¤Ï 1·å¤Î16¿Ê¿ô¤¬ÃÖ¤«¤ì¡¢¾®¿ôÅÀ¤Î¸å¤í¤Î·å¿ô¤Ï
1233 ÀºÅ٤ǻØÄꤵ¤ì¤¿ÃͤȤʤ롣
1234 .\"O The default precision suffices for an exact representation of the value
1235 .\"O if an exact representation in base 2 exists
1236 .\"O and otherwise is sufficiently large to distinguish values of type
1237 .\"O .IR double .
1238 ¥Ç¥Õ¥©¥ë¥È¤ÎÀºÅ٤ϡ¢¤½¤ÎÃͤ¬ 2¿Ê¿ô¤ÇÀµ³Î¤Ëɽ¸½¤Ç¤­¤ë¾ì¹ç¤Ë¤Ï¡¢
1239 ¤½¤ÎÃͤòÀµ³Î¤Ëɽ¸½¤Ç¤­¤ë·å¿ô¤È¤Ê¤ë¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢
1240 .I double
1241 ·¿¤ÎÃͤò¶èÊ̤¹¤ë¤Î¤Ë½½Ê¬¤ÊÂ礭¤µ¤È¤Ê¤ë¡£
1242 .\"O The digit before the decimal point is unspecified for nonnormalized
1243 .\"O numbers, and nonzero but otherwise unspecified for normalized numbers.
1244 .\" motoki 2005/03/19: ¹ç¤Ã¤Æ¤¤¤ë¤«¤Ê¡©
1245 ¾®¿ôÅÀ¤ÎÁ°¤Î¿ô»ú¤Ï¡¢Àµµ¬²½¤µ¤ì¤Æ¤¤¤Ê¤¤¿ô¤Î¾ì¹ç¤Ï¤¤¤¯¤Ä¤Ë¤Ê¤ë¤«Ê¬¤«¤é¤Ê¤¤¡£
1246 Àµµ¬²½¤µ¤ì¤¿¿ô¤Î¾ì¹ç¤Ï¡¢ 0 °Ê³°¤ÎÃͤˤʤ뤬¡¢¤¤¤¯¤Ä¤Ë¤Ê¤ë¤«¤Ïʬ¤«¤é¤Ê¤¤¡£
1247 .TP
1248 .B c
1249 .\"O If no
1250 .\"O .B l
1251 .\"O modifier is present, the
1252 .\"O .I int
1253 .\"O argument is converted to an
1254 .\"O .IR "unsigned char" ,
1255 .\"O and the resulting character is written.
1256 .B l
1257 ½¤¾þ»Ò¤¬¤Ê¤±¤ì¤Ð¡¢
1258 .I int
1259 °ú¤­¿ô¤ò
1260 .IR "unsigned char"
1261 ¤ËÊÑ´¹¤·¤Æ¡¢¤½¤Î·ë²Ì¤ËÂбþ¤¹¤ëʸ»ú¤ò½ÐÎϤ¹¤ë¡£
1262 .\"O If an
1263 .\"O .B l
1264 .\"O modifier is present, the
1265 .\"O .I wint_t
1266 .\"O (wide character) argument is converted to a multibyte sequence by a call
1267 .\"O to the
1268 .\"O .BR wcrtomb (3)
1269 .\"O function, with a conversion state starting in the initial state, and the
1270 .\"O resulting multibyte string is written.
1271 .B l
1272 ½¤¾þ»Ò¤¬¤¢¤ì¤Ð¡¢
1273 .I wint_t
1274 (¥ï¥¤¥Éʸ»ú) °ú¤­¿ô¤ò¡¢
1275 .BR wcrtomb (3)
1276 ´Ø¿ô¤ò½é´ü¥·¥Õ¥È¾õÂ֤ǸƤӽФ·¤Æ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ËÊÑ´¹¤·¡¢
1277 ÊÑ´¹¤µ¤ì¤¿¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò½ÐÎϤ¹¤ë¡£
1278 .TP
1279 .B s
1280 .\"O If no
1281 .\"O .B l
1282 .\"O modifier is present: The
1283 .\"O .I "const char *"
1284 .\"O argument is expected to be a pointer to an array of character type (pointer
1285 .\"O to a string).
1286 .\"O Characters from the array are written up to (but not
1287 .\"O including) a terminating null byte (\(aq\\0\(aq);
1288 .\"O if a precision is specified, no more than the number specified
1289 .\"O are written.
1290 .\"O If a precision is given, no null byte need be present;
1291 .\"O if the precision is not specified, or is greater than the size of the
1292 .\"O array, the array must contain a terminating null byte.
1293 .B l
1294 ½¤¾þ»Ò¤¬¤Ê¤¤¾ì¹ç¡¢
1295 °ú¤­¿ô¤Ï
1296 .I "const char *"
1297 ·¿¤Çʸ»ú·¿¤ÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ (ʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿) ¤Ç¤¢¤ë¤³¤È¤¬
1298 ´üÂÔ¤µ¤ì¤Æ¤¤¤ë¡£ÇÛÎóÃæ¤Îʸ»ú¤Ï¡¢½ªÃ¼¤Î NULL ¥Ð¥¤¥È (\(aq\\0\(aq)
1299 ¤¬½Ð¤Æ¤¯¤ë¤Þ¤Ç½ÐÎϤµ¤ì¤ë (½ªÃ¼Ê¸»ú¤Ï½ÐÎϤµ¤ì¤Ê¤¤)¡£
1300 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤È¡¢»ØÄꤵ¤ì¤¿»ú¿ô°Ê¾å¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£
1301 ÀºÅÙ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢½ªÃ¼¥Ð¥¤¥È¤¬Â¸ºß¤¹¤ëɬÍפϤʤ¤¡£
1302 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¤ê¡¢ÀºÅÙ¤ÎÃͤ¬ÇÛÎó¤ÎÂ礭¤µ¤è¤êÂ礭¤¤¾ì¹ç¤Ë¤Ï¡¢
1303 ÇÛÎó¤Ï½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤ò´Þ¤ó¤Ç¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1304
1305 .\"O If an
1306 .\"O .B l
1307 .\"O modifier is present: The
1308 .\"O .I "const wchar_t *"
1309 .\"O argument is expected to be a pointer to an array of wide characters.
1310 .B l
1311 ½¤¾þ»Ò¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
1312 °ú¤­¿ô¤Ï
1313 .I "const wchar_t *"
1314 ·¿¤Ç¥ï¥¤¥Éʸ»ú¤ÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤ë¡£
1315 .\"O Wide characters from the array are converted to multibyte characters
1316 .\"O (each by a call to the
1317 .\"O .BR wcrtomb (3)
1318 .\"O function, with a conversion state starting in the initial state before
1319 .\"O the first wide character), up to and including a terminating null
1320 .\"O wide character.
1321 .\"O The resulting multibyte characters are written up to
1322 .\"O (but not including) the terminating null byte.
1323 .\"O If a precision is
1324 .\"O specified, no more bytes than the number specified are written, but
1325 .\"O no partial multibyte characters are written.
1326 .\"O Note that the precision
1327 .\"O determines the number of
1328 .\"O .I bytes
1329 .\"O written, not the number of
1330 .\"O .I wide characters
1331 .\"O or
1332 .\"O .IR "screen positions" .
1333 ÇÛÎóÃæ¤Î¥ï¥¤¥Éʸ»ú¤Ï (1ʸ»úËè¤Ë
1334 .BR wcrtomb (3)
1335 ¤ò¸Æ¤Ó½Ð¤·¤Æ) ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤ËÊÑ´¹¤µ¤ì¤ë
1336 (ºÇ½é¤Î¥ï¥¤¥Éʸ»ú¤ÎÊÑ´¹¤ÎÁ°¤Ë
1337 .BR wcrtomb ()
1338 ¤Î¥·¥Õ¥È¾õÂÖ¤ò½é´ü¾õÂÖ¤ËÌᤷ¤Æ¤«¤éÊÑ´¹¤Ï¹Ô¤ï¤ì¤ë)¡£
1339 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤Ø¤ÎÊÑ´¹¤Ï¡¢Ê¸»úÎó¤ò½ªÃ¼¤¹¤ë NULL ¥ï¥¤¥Éʸ»ú¤¬
1340 ½Ð¤Æ¤¯¤ë¤Þ¤Ç¹Ô¤ï¤ì¡¢½ªÃ¼ NULL ¥ï¥¤¥Éʸ»ú¤â´Þ¤á¤ÆÊÑ´¹¤µ¤ì¤ë¡£
1341 ·ë²Ì¤Î¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤Ï¡¢½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤¬½Ð¤Æ¤¯¤ë¤Þ¤Ç
1342 ½ÐÎϤµ¤ì¤ë (½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Ï½ÐÎϤµ¤ì¤Ê¤¤)¡£
1343 ÀºÅÙ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢»ØÄꤵ¤ì¤¿¥Ð¥¤¥È¿ô°Ê¾å¤Ë¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£
1344 ⤷¡¢¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤Î°ìÉôʬ¤À¤±¤¬½ÐÎϤµ¤ì¤ë¤³¤È¤Ï¤Ê¤¤¡£
1345 ÀºÅ٤ϡ֥Х¤¥È¡×¿ô¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¤¢¤ê¡¢¡Ö¥ï¥¤¥Éʸ»ú¡×¿ô¤ä
1346 ¡Ö²èÌ̤ǤΰÌÃ֡פò»ØÄꤹ¤ë¤â¤Î¤Ç¤Ï¤Ê¤¤¤³¤È¤ËÃí°Õ¡£
1347 .\"O The array must contain a terminating null wide character, unless a
1348 .\"O precision is given and it is so small that the number of bytes written
1349 .\"O exceeds it before the end of the array is reached.
1350 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢¤µ¤é¤Ë½ÐÎϤ¬ÇÛÎó¤ÎËöÈø¤Ë㤹¤ëÁ°¤Ë½ÐÎϥХ¤¥È¿ô¤¬
1351 ÀºÅÙ¤ÎÃͤòĶ¤¨¤ë¾ì¹ç¤À¤±¤Ï¡¢ÇÛÎó¤Ï NULL ¥ï¥¤¥Éʸ»ú¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤¯¤Æ¤â¤è¤¤¡£
1352 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢É¬¤ºÇÛÎó¤Ï NULL ¥ï¥¤¥Éʸ»ú¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1353 .TP
1354 .B C
1355 .\"O (Not in C99, but in SUSv2.)
1356 .\"O Synonym for
1357 .\"O .BR lc .
1358 .\"O Don't use.
1359 (C99 ¤Ë¤Ï¤Ê¤¤¤¬ SUSv2 ¤Ë¤Ï¤¢¤ë)
1360 .B lc
1361 ¤ÈƱ¤¸¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1362 .TP
1363 .B S
1364 .\"O (Not in C99, but in SUSv2.)
1365 .\"O Synonym for
1366 .\"O .BR ls .
1367 .\"O Don't use.
1368 (C99 ¤Ë¤Ï¤Ê¤¤¤¬ SUSv2 ¤Ë¤Ï¤¢¤ë)
1369 .B ls
1370 ¤ÈƱ¤¸¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1371 .TP
1372 .B p
1373 .\"O The
1374 .\"O .I "void *"
1375 .\"O pointer argument is printed in hexadecimal (as if by
1376 .\"O .B %#x
1377 .\"O or
1378 .\"O .BR  %#lx ).
1379 .I "void *"
1380 ¥Ý¥¤¥ó¥¿°ú¤­¿ô¤ò
1381 .RB ( %#x
1382 ¤ä
1383 .BR  %#lx
1384 ¤Î¤è¤¦¤Ê) 16 ¿Ê¿ô¤Ç½ÐÎϤ¹¤ë¡£
1385 .TP
1386 .B n
1387 .\"O The number of characters written so far is stored into the integer
1388 .\"O indicated by the
1389 .\"O .I "int *"
1390 .\"O (or variant) pointer argument.
1391 .\"O No argument is converted.
1392 ¤³¤ì¤Þ¤Ç¤Ë½ÐÎϤµ¤ì¤¿Ê¸»ú¿ô¤ò
1393 .I "int *"
1394 (¤Þ¤¿¤ÏÎà»÷¤Î·¿) ¤Î¥Ý¥¤¥ó¥¿°ú¤­¿ô¤¬»Ø¤¹À°¿ô¤ËÊݸ¤¹¤ë¡£
1395 °ú¤­¿ô¤ÎÊÑ´¹¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
1396 .TP
1397 .B m
1398 .\"O (Glibc extension.)
1399 .\"O Print output of
1400 .\"O .IR strerror(errno) .
1401 .\"O No argument is required.
1402 (glibc ¤Ç¤Î³ÈÄ¥)
1403 .I strerror(errno)
1404 ¤Î½ÐÎϤòɽ¼¨¤¹¤ë¡£°ú¤­¿ô¤ÏɬÍפʤ¤¡£
1405 .TP
1406 .B %
1407 .\"O A \(aq%\(aq is written.
1408 .\"O No argument is converted.
1409 .\"O The complete conversion
1410 .\"O specification is \(aq%%\(aq.
1411 \(aq%\(aq Ê¸»ú¤ò½ÐÎϤ¹¤ë¡£ÊÑ´¹¤µ¤ì¤ë°ú¤­¿ô¤Ï̵¤¤¡£
1412 ÊÑ´¹»ØÄêÁ´ÂΤò½ñ¤¯¤È "%%" ¤È¤Ê¤ë¡£
1413 .\"O .SH "CONFORMING TO"
1414 .SH ½àµò
1415 .\"O The
1416 .\"O .BR fprintf (),
1417 .\"O .BR printf (),
1418 .\"O .BR sprintf (),
1419 .\"O .BR vprintf (),
1420 .\"O .BR vfprintf (),
1421 .\"O and
1422 .\"O .BR vsprintf ()
1423 .\"O functions conform to C89 and C99.
1424 .BR fprintf (),
1425 .BR printf (),
1426 .BR sprintf (),
1427 .BR vprintf (),
1428 .BR vfprintf (),
1429 .BR vsprintf ()
1430 ´Ø¿ô¤Ï¡¢C89 ¤È C99 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
1431 .\"O The
1432 .\"O .BR snprintf ()
1433 .\"O and
1434 .\"O .BR vsnprintf ()
1435 .\"O functions conform to C99.
1436 .BR snprintf ()
1437 ¤È
1438 .BR vsnprintf ()
1439 ¤Ï C99 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
1440 .PP
1441 .\"O Concerning the return value of
1442 .\"O .BR snprintf (),
1443 .\"O SUSv2 and C99 standard contradict each other: when
1444 .\"O .BR snprintf ()
1445 .\"O is called with
1446 .\"O .IR size =0
1447 .\"O then SUSv2 stipulates an unspecified return value less than 1,
1448 .\"O while C99 allows
1449 .\"O .I str
1450 .\"O to be NULL in this case, and gives the return value (as always)
1451 .\"O as the number of characters that would have been written in case
1452 .\"O the output string has been large enough.
1453 .BR snprintf ()
1454 ¤ÎÊÖ¤êÃͤò¸«¤ë¤È¡¢
1455 SUSv2 ¤È C99 É¸½à¤Ï¸ß¤¤¤ËÌ·½â¤·¤Æ¤¤¤ë¡£
1456 SUSv2 ¤Ç¤Ï¡¢
1457 .BR snprintf ()
1458 ¤¬
1459 .IR size =0
1460 ¤Ç¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢ 1 Ì¤Ëþ¤ÎÃͤò²¿¤«ÊÖ¤êÃͤȤ¹¤ë¤è¤¦¤Ëµ¬Äꤷ¤Æ¤¤¤ë¡£
1461 °ìÊý C99 ¤Ç¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾ì¹ç
1462 .I str
1463 ¤ò NULL ¤È¤·¡¢ÊÖ¤êÃͤȤ·¤Æ (Ä̾ïÄ̤ê) ½ÐÎϥХåե¡¤¬½½Ê¬¤ÊÂ礭¤µ¤¬
1464 ¤¢¤Ã¤¿¾ì¹ç¤Ë½ÐÎϤµ¤ì¤ë¤Ç¤¢¤í¤¦Ê¸»ú¿ô¤òÊÖ¤¹¡£
1465 .PP
1466 .\"O Linux libc4 knows about the five C standard flags.
1467 .\"O It knows about the length modifiers \fBh\fP, \fBl\fP, \fBL\fP,
1468 .\"O and the conversions
1469 .\"O \fBc\fP, \fBd\fP, \fBe\fP, \fBE\fP, \fBf\fP, \fBF\fP,
1470 .\"O \fBg\fP, \fBG\fP, \fBi\fP, \fBn\fP, \fBo\fP, \fBp\fP,
1471 .\"O \fBs\fP, \fBu\fP, \fBx\fP, and \fBX\fP,
1472 .\"O where \fBF\fP is a synonym for \fBf\fP.
1473 Linux libc4 ¤Ç¤Ï¡¢ 5 ¤Ä¤Î C É¸½à¤Î¥Õ¥é¥°¡¢
1474 Ťµ½¤¾þ»Ò \fBh\fP, \fBl\fP, \fBL\fP¡¢ÊÑ´¹
1475 \fBc\fP, \fBd\fP, \fBe\fP, \fBE\fP, \fBf\fP, \fBF\fP,
1476 \fBg\fP, \fBG\fP, \fBi\fP, \fBn\fP, \fBo\fP, \fBp\fP,
1477 \fBs\fP, \fBu\fP, \fBx\fP, \fBX\fP
1478 ¤¬»È¤¨¤ë¡£
1479 ⤷ \fBF\fP ¤Ï \fBf\fP ¤ÈƱµÁ¤Ç¤¢¤ë¡£
1480 .\"O Additionally, it accepts \fBD\fP, \fBO\fP, and \fBU\fP as synonyms
1481 .\"O for \fBld\fP, \fBlo\fP, and \fBlu\fP.
1482 .\"O (This is bad, and caused serious bugs later, when
1483 .\"O support for \fB%D\fP disappeared.)
1484 .\"O No locale-dependent radix character,
1485 .\"O no thousands' separator, no NaN or infinity, no "%m$" and "*m$".
1486 ¤Þ¤¿¡¢ \fBD\fP, \fBO\fP, and \fBU\fP ¤ò \fBld\fP, \fBlo\fP, and \fBlu\fP
1487 ¤ÈƱ¤¸¤â¤Î¤È¤·¤Æ»È¤¨¤ë
1488 (¤³¤ì¤Ï¤Þ¤º¤¤»ÅÍͤǡ¢ ¸å¤Ë \fB%D\fP ¤ÎÂбþ¤¬ÂǤÁÀÚ¤é¤ì¤¿»þ¤Ë¿¼¹ï¤Ê¥Ð¥°¤ò
1489 °ú¤­µ¯¤³¤·¤¿)¡£¥í¥±¡¼¥ë°Í¸¤Î¾®¿ôÅÀ¡¢1000 ¶èÀڤꡢ NaN ¤È̵¸Â¡¢
1490 "%m$" ¤È "*m$" ¤Ï»È¤¨¤Ê¤¤¡£
1491 .PP
1492 .\"O Linux libc5 knows about the five C standard flags and the \(aq flag,
1493 .\"O locale, "%m$" and "*m$".
1494 .\"O It knows about the length modifiers \fBh\fP, \fBl\fP, \fBL\fP,
1495 .\"O \fBZ\fP, and \fBq\fP, but accepts \fBL\fP and \fBq\fP
1496 .\"O both for \fIlong double\fP and for \fIlong long int\fP (this is a bug).
1497 Linux libc5 ¤Ç¤Ï¡¢ 5 ¤Ä¤Î C É¸½à¤Î¥Õ¥é¥°¤È \(aq ¥Õ¥é¥°¡¢¥í¥±¡¼¥ë¡¢
1498 "%m$" ¤È "*m$" ¤¬»È¤¨¤ë¡£
1499 ¤Þ¤¿¡¢Ä¹¤µ½¤¾þ»Ò \fBh\fP, \fBl\fP, \fBL\fP, \fBZ\fP, iand \fBq\fP ¤¬»È¤¨¤ë¤¬¡¢
1500 \fBL\fP ¤È \fBq\fP ¤ÏξÊý¤È¤â
1501 \fIlong double\fP ¤È \fIlong long int\fP ¤ËÂбþ¤·¤Æ¤¤¤ë (¤³¤ì¤Ï¥Ð¥°¤Ç¤¢¤ë)¡£
1502 .\"O It no longer recognizes \fBF\fP, \fBD\fP, \fBO\fP, and \fBU\fP,
1503 .\"O but adds the conversion character
1504 .\"O .BR m ,
1505 .\"O which outputs
1506 .\"O .IR strerror(errno) .
1507 ¸½ºß¤Ç¤ÏÊÑ´¹ \fBF\fP, \fBD\fP, \fBO\fP, \fBU\fP ¤Ïǧ¼±¤µ¤ì¤Ê¤¤¤¬¡¢ÊÑ´¹Ê¸»ú
1508 .B m
1509 ¤¬Äɲ䵤줿¡£¤³¤ì¤Ï
1510 .I strerror(errno)
1511 ¤ò½ÐÎϤ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
1512 .PP
1513 .\"O glibc 2.0 adds conversion characters \fBC\fP and \fBS\fP.
1514 glibc 2.0 ¤Ç¤Ï¡¢ÊÑ´¹Ê¸»ú \fBC\fP ¤È \fBS\fP ¤¬Äɲ䵤줿¡£
1515 .PP
1516 .\"O glibc 2.1 adds length modifiers \fBhh\fP, \fBj\fP, \fBt\fP, and \fBz\fP
1517 .\"O and conversion characters \fBa\fP and \fBA\fP.
1518 glibc 2.1 ¤Ç¤Ï¡¢Ä¹¤µ½¤¾þ»Ò \fBhh\fP, \fBj\fP, \fBt\fP, \fBz\fP
1519 ¤ÈÊÑ´¹Ê¸»ú \fBa\fP, \fBA\fP ¤¬Äɲ䵤줿¡£
1520 .PP
1521 .\"O glibc 2.2 adds the conversion character \fBF\fP with C99 semantics,
1522 .\"O and the flag character \fBI\fP.
1523 glibc 2.2 ¤Ç¤Ï¡¢ C99 ¤Çµ¬Äꤵ¤ì¤¿°ÕÌ£¤Ç¤ÎÊÑ´¹Ê¸»ú \fBF\fP ¤È
1524 ¥Õ¥é¥°Ê¸»ú \fBI\fP ¤¬Äɲ䵤줿¡£
1525 .\"O .SH NOTES
1526 .SH Ãí°Õ
1527 .\"O Some programs imprudently rely on code such as the following
1528 .\"O 
1529 .\"O     sprintf(buf, "%s some further text", buf);
1530 .\"O 
1531 .\"O to append text to
1532 .\"O .IR buf .
1533 ¥Æ¥­¥¹¥È¤ò
1534 .I buf
1535 ¤ËÄɲ乤ë¤Î¤Ë¡¢·ÚΨ¤Ë¤â¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤Ã¤Æ¤¤¤ë¥×¥í¥°¥é¥à¤¬¤¢¤ë¡£
1536
1537     sprintf(buf, "%s some further text", buf);
1538
1539 .\"O However, the standards explicitly note that the results are undefined
1540 .\"O if source and destination buffers overlap when calling
1541 .\"O .BR sprintf (),
1542 .\"O .BR snprintf (),
1543 .\"O .BR vsprintf (),
1544 .\"O and
1545 .\"O .BR vsnprintf ().
1546 ¤·¤«¤·¤Ê¤¬¤é¡¢É¸½àµ¬³Ê¤Ç¤Ï¡¢
1547 .BR sprintf (),
1548 .BR snprintf (),
1549 .BR vsprintf (),
1550 .BR vsnprintf ()
1551 ¤Î¸Æ¤Ó½Ð¤·¤Ë¤ª¤¤¤Æ¡¢¥³¥Ô¡¼¸µ¤È¥³¥Ô¡¼Àè¤Î¥Ð¥Ã¥Õ¥¡¤¬½Å¤Ê¤Ã¤Æ¤¤¤¿¾ì¹ç¤Î
1552 ·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¡¢¤ÈÌÀµ­¤µ¤ì¤Æ¤¤¤ë¡£
1553 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7075
1554 .\"O Depending on the version of
1555 .\"O .BR gcc (1)
1556 .\"O used, and the compiler options employed, calls such as the above will
1557 .\"O .B not
1558 .\"O produce the expected results.
1559 »ÈÍѤ¹¤ë
1560 .BR gcc (1)
1561 ¤Î¥Ð¡¼¥¸¥ç¥ó¤ä»ØÄꤷ¤¿¥³¥ó¥Ñ¥¤¥é¤Î¥ª¥×¥·¥ç¥ó¼¡Âè¤Ç¤Ï¡¢
1562 ¾åµ­¤Î¤è¤¦¤Ê¸Æ¤Ó½Ð¤·¤Ç¡¢´üÂÔ¤·¤¿·ë²Ì¤¬ÆÀ¤é¤ì¡Ö¤Ê¤¤¡×¤³¤È¤¬¤¢¤ë¡£
1563
1564 .\"O The glibc implementation of the functions
1565 .\"O .BR snprintf ()
1566 .\"O and
1567 .\"O .BR vsnprintf ()
1568 .\"O conforms to the C99 standard, that is, behaves as described above,
1569 .\"O since glibc version 2.1.
1570 .\"O Until glibc 2.0.6 they would return \-1
1571 .\"O when the output was truncated.
1572 glibc ¤Î
1573 .BR snprintf ()
1574 ¤È
1575 .BR vsnprintf ()
1576 ¤Î¼ÂÁõ¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Ï C99 É¸½à¤Ë½àµò¤·¤Æ¤ª¤ê¡¢
1577 ¾åµ­¤ÎÄ̤ê¤ÎÆ°ºî¤ò¤¹¤ë¡£
1578 glibc 2.0.6 ¤Þ¤Ç¤Ï¡¢½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
1579 .\"O .\" .SH HISTORY
1580 .\" .SH Îò»Ë
1581 .\"O .\" Unix V7 defines the three routines
1582 .\"O .\" .BR printf (),
1583 .\"O .\" .BR fprintf (),
1584 .\"O .\" .BR sprintf (),
1585 .\"O .\" and has the flag \-, the width or precision *, the length modifier l,
1586 .\"O .\" and the conversions doxfegcsu, and also D,O,U,X as synonyms for ld,lo,lu,lx.
1587 .\" Unix V7 ¤Ç¤Ï
1588 .\" .BR printf (),
1589 .\" .BR fprintf (),
1590 .\" .BR sprintf ()
1591 .\" ¤Î 3 ¤Ä¤Î´Ø¿ô¤È¡¢¥Õ¥é¥° \-¡¢Éý¤ÈÀºÅ٤ǤΠ*¡¢Ä¹¤µ½¤¾þ»Ò l¡¢
1592 .\" ÊÑ´¹ doxfegcsu¡¢¤½¤·¤Æ ld,ld,lu,lx ¤ÎƱµÁ¸ì¤È¤·¤Æ D,O,U,X ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
1593 .\"O .\" This is still true for 2.9.1BSD, but 2.10BSD has the flags
1594 .\"O .\" #, + and <space> and no longer mentions D,O,U,X.
1595 .\" 2.9.1BSD ¤Ç¤â¤³¤ì¤ÏƱ¤¸¤À¤Ã¤¿¤¬¡¢ 2.10BSD ¤Ç¤Ï
1596 .\" ¥Õ¥é¥° #, +, ¶õÇò¤¬Äɲ䵤졢 D,O,U,X ¤Ë¤Ä¤¤¤Æ¤Ïµ­ºÜ¤µ¤ì¤Ê¤¯¤Ê¤Ã¤¿¡£
1597 .\"O .\" 2.11BSD has
1598 .\"O .\" .BR vprintf (),
1599 .\"O .\" .BR vfprintf (),
1600 .\"O .\" .BR vsprintf (),
1601 .\"O .\" and warns not to use D,O,U,X.
1602 .\" 2.11BSD ¤Ç¤Ï
1603 .\" .BR vprintf (),
1604 .\" .BR vfprintf (),
1605 .\" .BR vsprintf ()
1606 .\" ¤¬Äɲ䵤졢 D,O,U,X ¤ò»È¤ï¤Ê¤¤¤è¤¦¤Ë·Ù¹ð¤µ¤ì¤¿¡£
1607 .\"O .\" 4.3BSD Reno has the flag 0, the length modifiers h and L,
1608 .\"O .\" and the conversions n, p, E, G, X (with current meaning)
1609 .\"O .\" and deprecates D,O,U.
1610 .\" 4.3BSD Reno ¤Ç¤Ï¥Õ¥é¥° 0¡¢Ä¹¤µ½¤¾þ»Ò h ¤È L¡¢
1611 .\" ÊÑ´¹ n, p, E, G, (¸½ºß¤Î°ÕÌ£¤Ç¤Î) X ¤¬Äɲ䵤졢
1612 .\" D,O,U ¤ÏÈó¿ä¾©°·¤¤¤È¤Ê¤Ã¤¿¡£
1613 .\"O .\" 4.4BSD introduces the functions
1614 .\"O .\" .BR snprintf ()
1615 .\"O .\" and
1616 .\"O .\" .BR vsnprintf (),
1617 .\"O .\" and the length modifier q.
1618 .\" 4.4BSD ¤Ç¤Ï¡¢´Ø¿ô
1619 .\" .BR snprintf ()¤È
1620 .\" .BR vsnprintf ()¡¢
1621 .\" Ä¹¤µ½¤¾þ»Ò q ¤¬Æ³Æþ¤µ¤ì¤¿¡£
1622 .\"O .\" FreeBSD also has functions
1623 .\"O .\" .BR asprintf ()
1624 .\"O .\" and
1625 .\"O .\" .BR vasprintf (),
1626 .\"O .\" that allocate a buffer large enough for
1627 .\"O .\" .BR sprintf ().
1628 .\" FreeBSD ¤Ç¤Ï¡¢
1629 .\" .BR sprintf ()
1630 .\" ¤Î¤¿¤á¤Ë½½Ê¬¤Ê¥Ð¥Ã¥Õ¥¡¤ò³ÎÊݤ¹¤ë
1631 .\" .BR asprintf ()
1632 .\" ¤È
1633 .\" .BR vasprintf ()
1634 .\" ¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
1635 .\"O .\" In glibc there are functions
1636 .\"O .\" .BR dprintf ()
1637 .\"O .\" and
1638 .\"O .\" .BR vdprintf ()
1639 .\"O .\" that print to a file descriptor instead of a stream.
1640 .\" glibc ¤Ë¤Ï¡¢´Ø¿ô
1641 .\" .BR dprintf (),
1642 .\" .BR vdprintf ()
1643 .\" ¤¬¤¢¤ê¡¢¤³¤ì¤é¤Ï¥¹¥È¥ê¡¼¥à¤Ç¤Ï¤Ê¤¯¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë½ÐÎϤ¹¤ë¡£
1644 .\"O .SH BUGS
1645 .SH ¥Ð¥°
1646 .\"O Because
1647 .\"O .BR sprintf ()
1648 .\"O and
1649 .\"O .BR vsprintf ()
1650 .\"O assume an arbitrarily long string, callers must be careful not to overflow
1651 .\"O the actual space; this is often impossible to assure.
1652 .\"O Note that the length
1653 .\"O of the strings produced is locale-dependent and difficult to predict.
1654 .BR sprintf ()
1655 ¤È
1656 .BR vsprintf ()
1657 ¤Ï¾¡¼ê¤Ë½½Ê¬¤ËŤ¤Ê¸»úÎóÎΰ褬¤¢¤ë¤È²¾Äꤹ¤ë¤Î¤Ç¡¢¸Æ¤Ó½Ð¤·Â¦¤Ï
1658 ¼ÂºÝ¤ÎÎΰ褫¤é¤¢¤Õ¤ì¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1659 ¤·¤«¤·¡¢¤³¤ì¤òÊݾڤ¹¤ë¤³¤È¤¬ÉÔ²Äǽ¤Ê¾ì¹ç¤¬Â¿¤¤¡£
1660 À¸À®¤µ¤ì¤ëʸ»úÎó¤ÎŤµ¤Ï¥í¥±¡¼¥ë°Í¸¤Ç¤¢¤ê¡¢Í½Â¬¤¬Æñ¤·¤¤¤³¤È¤ËÃí°Õ¡£
1661 .\"O Use
1662 .\"O .BR snprintf ()
1663 .\"O and
1664 .\"O .BR vsnprintf ()
1665 .\"O instead (or
1666 .\"O .BR asprintf (3)
1667 .\"O and
1668 .\"O .BR vasprintf (3)).
1669 Âå¤ï¤ê¤Ë
1670 .BR snprintf ()
1671 ¤È
1672 .BR vsnprintf ()
1673 (¤Þ¤¿¤Ï
1674 .BR asprintf (3)
1675 ¤È
1676 .BR vasprintf (3))
1677 ¤ò»È¤¦¤³¤È¡£
1678 .PP
1679 .\"O Linux libc4.[45] does not have a
1680 .\"O .BR snprintf (),
1681 .\"O but provides a libbsd that contains an
1682 .\"O .BR snprintf ()
1683 .\"O equivalent to
1684 .\"O .BR sprintf (),
1685 .\"O that is, one that ignores the
1686 .\"O .I size
1687 .\"O argument.
1688 Linux libc4.[45] ¤Ë¤Ï
1689 .BR snprintf ()
1690 ¤Ï¤Ê¤¤¤¬¡¢ libbsd ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢
1691 ¤½¤ÎÃæ¤Ë¤Ï
1692 .BR sprintf ()
1693 ¤ÈÅù²Á¤Ê (¤Ä¤Þ¤ê
1694 .I size
1695 °ú¤­¿ô¤ò̵»ë¤¹¤ë)
1696 .BR snprintf ()
1697 ¤¬¤¢¤ë¡£
1698 .\"O Thus, the use of
1699 .\"O .BR snprintf ()
1700 .\"O with early libc4 leads to serious security problems.
1701 ¤·¤¿¤¬¤Ã¤Æ¡¢½é´ü¤Î libc4 ¤Ç
1702 .BR snprintf ()
1703 ¤ò»È¤¦¤È¡¢¿¼¹ï¤Ê¥»¥­¥å¥ê¥Æ¥£ÌäÂê¤ò°ú¤­µ¯¤³¤¹¤³¤È¤¬¤¢¤ë¡£
1704 .PP
1705 .\"O Code such as
1706 .\"O .BI printf( foo );
1707 .\"O often indicates a bug, since
1708 .\"O .I foo
1709 .\"O may contain a % character.
1710 .\"O If
1711 .\"O .I foo
1712 .\"O comes from untrusted user input, it may contain \fB%n\fP, causing the
1713 .\"O .BR printf ()
1714 .\"O call to write to memory and creating a security hole.
1715 .BI printf( foo );
1716 ¤Î¤è¤¦¤Ê¥³¡¼¥É¤Ï¤·¤Ð¤·¤Ð¥Ð¥°¤ò°ú¤­µ¯¤³¤¹¡£
1717 ¤Ê¤¼¤Ê¤é
1718 .I foo
1719 ¤Ë % Ê¸»ú¤¬´Þ¤Þ¤ì¤Æ¤ë¤«¤â¤·¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
1720 .I foo
1721 ¤¬¿®Íê¤Ç¤­¤Ê¤¤¥æ¡¼¥¶¡¼ÆþÎϤ«¤éºî¤é¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
1722 ¤½¤ÎÃæ¤Ë \fB%n\fP ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ê¡¢
1723 .BR printf ()
1724 ¸Æ¤Ó½Ð¤·»þ¤Ë¥á¥â¥ê¤Ø¤Î½ñ¤­¹þ¤ß¤¬µ¯¤³¤ê¡¢
1725 ¥»¥­¥å¥ê¥Æ¥£¡¼¥Û¡¼¥ë¤òºî¤ë¤³¤È¤Ë¤Ê¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1726 .\".PP
1727 .\".\"O Some floating-point conversions under early libc4
1728 .\".\"O caused memory leaks.
1729 .\"½é´ü¤Î libc4 ¤Ç¤Î¼Â¿ôÊÑ´¹¤Ë¤Ï¥á¥â¥ê¥ê¡¼¥¯¤ò°ú¤­µ¯¤³¤¹¤³¤È¤¬¤¢¤ë¡£
1730 .\"O .SH EXAMPLE
1731 .SH Îã
1732 .if \w'\*(Pi'=0 .ds Pi pi
1733 .\"O To print \*(Pi to five decimal places:
1734 \*(Pi ¤ò 5 ·å¤Ç½ÐÎϤ¹¤ë¡£
1735 .in +4n
1736 .nf
1737
1738 #include <math.h>
1739 #include <stdio.h>
1740 fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0));
1741 .fi
1742 .in
1743 .PP
1744 .\"O To print a date and time in the form "Sunday, July 3, 10:02",
1745 .\"O where
1746 .\"O .I weekday
1747 .\"O and
1748 .\"O .I month
1749 .\"O are pointers to strings:
1750 ÆüÉդȻþ´Ö¤ò "Sunday, July 3, 10:02" ¤Î·Á¼°¤Ç½ÐÎϤ¹¤ë¡£
1751 .RI ( weekday
1752 ¤È
1753 .I month
1754 ¤Ïʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë)
1755 .in +4n
1756 .nf
1757
1758 #include <stdio.h>
1759 fprintf(stdout, "%s, %s %d, %.2d:%.2d\en",
1760         weekday, month, day, hour, min);
1761 .fi
1762 .in
1763 .PP
1764 .\"O Many countries use the day-month-year order.
1765 .\"O Hence, an internationalized version must be able to print
1766 .\"O the arguments in an order specified by the format:
1767 Æü - ·î - Ç¯ ¤Î½ç½ø¤Çɽ¼¨¤ò¹Ô¤¦¹ñ¤â¿¤¤¡£
1768 ½¾¤Ã¤Æ¡¢¹ñºÝÈǤǤϽñ¼°¤Ç»ØÄꤵ¤ì¤¿½çÈÖ¤Ç
1769 °ú¤­¿ô¤òɽ¼¨¤Ç¤­¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1770 .in +4n
1771 .nf
1772
1773 #include <stdio.h>
1774 fprintf(stdout, format,
1775         weekday, month, day, hour, min);
1776
1777 .fi
1778 .in
1779 .\"O where
1780 .\"O .I format
1781 .\"O depends on locale, and may permute the arguments.
1782 .\"O With the value:
1783 .I format
1784 ¤Ï¥í¥±¡¼¥ë¤Ë°Í¸¤·¤Æ¤ª¤ê¡¢°ú¤­¿ô¤Î½çÈÖ¤òÊѤ¨¤ë¤³¤È¤â¤Ç¤­¤ë¡£
1785 .I format
1786 ¤¬
1787 .in +4n
1788 .nf
1789
1790 "%1$s, %3$d. %2$s, %4$d:%5$.2d\en"
1791
1792 .fi
1793 .in
1794 .\"O one might obtain "Sonntag, 3. Juli, 10:02".
1795 ¤Ç¤¢¤ì¤Ð¡¢ "Sonntag, 3. Juli, 10:02" ¤È¤¤¤¦·ë²Ì¤Ë¤Ê¤ë¡£
1796 .PP
1797 .\"O To allocate a sufficiently large string and print into it
1798 .\"O (code correct for both glibc 2.0 and glibc 2.1):
1799 ½½Ê¬¤ËÂ礭¤Êʸ»úÎóÎΰè¤ò³ÎÊݤ·¤Æ¡¢¤½¤³¤Ë¥á¥Ã¥»¡¼¥¸¤ò³ÊǼ¤¹¤ë¤Ë¤Ï
1800 (glibc 2.0 ¤È glibc 2.1 ¤ÎξÊý¤ÇÀµ¤·¤¯Æ°ºî¤¹¤ë¥³¡¼¥É):
1801 .nf
1802
1803 #include <stdio.h>
1804 #include <stdlib.h>
1805 #include <stdarg.h>
1806 char *
1807 make_message(const char *fmt, ...)
1808 {
1809     /* Guess we need no more than 100 bytes. */
1810     int n, size = 100;
1811     char *p, *np;
1812     va_list ap;
1813
1814     if ((p = malloc(size)) == NULL)
1815         return NULL;
1816
1817     while (1) {
1818         /* Try to print in the allocated space. */
1819         va_start(ap, fmt);
1820         n = vsnprintf(p, size, fmt, ap);
1821         va_end(ap);
1822         /* If that worked, return the string. */
1823         if (n > \-1 && n < size)
1824             return p;
1825         /* Else try again with more space. */
1826         if (n > \-1)    /* glibc 2.1 */
1827             size = n+1; /* precisely what is needed */
1828         else           /* glibc 2.0 */
1829             size *= 2;  /* twice the old size */
1830         if ((np = realloc (p, size)) == NULL) {
1831             free(p);
1832             return NULL;
1833         } else {
1834             p = np;
1835         }
1836     }
1837 }
1838 .fi
1839 .\"O .SH "SEE ALSO"
1840 .SH ´ØÏ¢¹àÌÜ
1841 .BR printf (1),
1842 .BR asprintf (3),
1843 .BR dprintf (3),
1844 .BR scanf (3),
1845 .BR setlocale (3),
1846 .BR wcrtomb (3),
1847 .BR wprintf (3),
1848 .BR locale (5)