1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
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.
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.
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.
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,
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.
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
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
45 .\" WORD: conversion specifier ÊÑ´¹»ØÄê»Ò
46 .\" WORD: length modifier Ťµ½¤¾þ»Ò
48 .TH PRINTF 3 2011-09-28 "GNU" "Linux Programmer's Manual"
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 \- »ØÄꤵ¤ì¤¿½ñ¼°¤ËÊÑ´¹¤·¤Æ½ÐÎϤò¹Ô¤¦
59 .BI "int printf(const char *" format ", ...);"
61 .BI "int fprintf(FILE *" stream ", const char *" format ", ...);"
63 .BI "int sprintf(char *" str ", const char *" format ", ...);"
65 .BI "int snprintf(char *" str ", size_t " size ", const char *" format ", ...);"
67 .B #include <stdarg.h>
69 .BI "int vprintf(const char *" format ", va_list " ap );
71 .BI "int vfprintf(FILE *" stream ", const char *" format ", va_list " ap );
73 .BI "int vsprintf(char *" str ", const char *" format ", va_list " ap );
75 .BI "int vsnprintf(char *" str ", size_t " size ", const char *" format \
79 .\"O Feature Test Macro Requirements for glibc (see
80 .\"O .BR feature_test_macros (7)):
81 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
82 .RB ( feature_test_macros (7)
90 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE ||
91 _POSIX_C_SOURCE\ >=\ 200112L;
99 .\"O The functions in the
101 .\"O family produce output according to a
103 .\"O as described below.
105 ´Ø¿ô¥°¥ë¡¼¥×¤Ï¡¢°Ê²¼¤Ç½Ò¤Ù¤ë¤è¤¦¤Ë¡¢
107 ¤Ë½¾¤Ã¤Æ½ÐÎϤòÀ¸À®¤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
114 .\"O the standard output stream;
118 .\"O write output to the given output
121 .\"O .BR snprintf (),
124 .\"O .BR vsnprintf ()
125 .\"O write to the character string
132 (ɸ½à½ÐÎÏ¥¹¥È¥ê¡¼¥à) ¤Ë½ñ¤½Ð¤¹¡£
136 ¤Ï½ÐÎϤò»ØÄꤵ¤ì¤¿½ÐÎÏ
150 .\"O .BR vsnprintf ()
153 .\"O bytes (including the terminating null byte (\(aq\e0\(aq)) to
164 ¤Ë¤Ïʸ»úÎó¤ò½ªÃ¼¤¹¤ë NULL ¥Ð¥¤¥È (\(aq\e0\(aq) ¤â¤ò´Þ¤Þ¤ì¤ë)¡£
168 .\"O .BR vfprintf (),
169 .\"O .BR vsprintf (),
170 .\"O .BR vsnprintf ()
171 .\"O are equivalent to the functions
175 .\"O .BR snprintf (),
176 .\"O respectively, except that they are called with a
178 .\"O instead of a variable number of arguments.
179 .\"O These functions do not call the
182 .\"O Because they invoke the
184 .\"O macro, the value of
186 .\"O is undefined after the call.
198 ¤Î³Æ´Ø¿ô¤ÈÅù²Á¤Ç¤¢¤ê¡¢²ÄÊÑ¿ô°ú¤¿ô¤ÎÂå¤ï¤ê¤Ë
200 ¤ò°ú¤¿ô¤È¤·¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ëÅÀ¤À¤±¤¬°Û¤Ê¤ë¡£
203 ¥Þ¥¯¥í¤Ï¸Æ¤Ó½Ð¤µ¤ì¤Ê¤¤¡£
206 ¤ò¸Æ¤Ó½Ð¤¹¤Î¤Ç¡¢¸Æ¤Ó½Ð¤·¸å¤Î
212 .\"O These eight functions write the output under the control of a
214 .\"O string that specifies how subsequent arguments (or arguments accessed via
215 .\"O the variable-length argument facilities of
217 .\"O are converted for output.
218 ¤³¤ì¤é¤Î 8 ¤Ä¤Î´Ø¿ô¤Ï
220 ʸ»úÎó¤ÎÀ©¸æ¤Ë½¾¤Ã¤Æ½ÐÎϤò½ñ¤½Ð¤¹¡£
222 ʸ»úÎó¤Ï¡¢¤³¤ì¤Ë³¤¯°ú¤¿ô (¤Þ¤¿¤Ï
224 ¤Î²ÄÊÑĹ°ú¤¿ôµ¡¹½¤ò»È¤Ã¤Æ¥¢¥¯¥»¥¹¤Ç¤¤ë°ú¤¿ô)
225 ¤ò¤É¤Î¤è¤¦¤ËÊÑ´¹¤·¤Æ½ÐÎϤ¹¤ë¤«¤ò»ØÄꤹ¤ë¡£
227 .\"O C99 and POSIX.1-2001 specify that the results are undefined if a call to
229 .\"O .BR snprintf (),
230 .\"O .BR vsprintf (),
232 .\"O .BR vsnprintf ()
233 .\"O would cause copying to take place between objects that overlap
234 .\"O (e.g., if the target string array and one of the supplied input arguments
235 .\"O refer to the same buffer).
237 C99 ¤È POSIX.1-2001 ¤Ç¤Ï¡¢
242 ¤Î¸Æ¤Ó½Ð¤·¤Ç¡¢ÈϰϤ¬½ÅÊ£¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È´Ö¤Ç¥³¥Ô¡¼¤¬È¯À¸¤¹¤ë¾ì¹ç¤Î
243 ·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¤Èµ¬Äꤵ¤ì¤Æ¤¤¤ë (Î㤨¤Ð¡¢½ÐÎÏÀè¤Îʸ»úÎó¤ÈÆþÎϤµ¤ì¤¿
244 °ú¤¿ô¤Î°ì¤Ä¤¬Æ±¤¸¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤Ê¤É¤Ç¤¢¤ë)¡£
246 .\"O .SS "Return value"
248 .\"O Upon successful return, these functions return the number of characters
249 .\"O printed (excluding the null byte used to end output to strings).
250 À®¸ù»þ¤Ë¤Ï¡¢¾åµ¤Î´Ø¿ô¤Ï½ñ¤¹þ¤Þ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹
251 (ʸ»úÎó¤ÎºÇ¸å¤ò¼¨¤¹¤¿¤á¤Ë»ÈÍѤ¹¤ë NULL ¥Ð¥¤¥È¤Ï¿ô¤Ë´Þ¤Þ¤ì¤Ê¤¤)¡£
256 .\"O .BR vsnprintf ()
257 .\"O do not write more than
259 .\"O bytes (including the terminating null byte (\(aq\e0\(aq)).
260 .\"O If the output was truncated due to this limit then the return value
261 .\"O is the number of characters (excluding the terminating null byte)
262 .\"O which would have been written to the final string if enough space
263 .\"O had been available.
264 .\"O Thus, a return value of
266 .\"O or more means that the output was truncated.
267 .\"O (See also below under NOTES.)
273 ¥Ð¥¤¥È¤ò±Û¤¨¤ëʸ»ú¿ô¤ò½ñ¤¹þ¤Þ¤Ê¤¤
275 ¤Ë¤Ïʸ»úÎó¤ò½ªÃ¼¤¹¤ë NULL ¥Ð¥¤¥È (\(aq\e0\(aq) ¤â´Þ¤Þ¤ì¤ë)¡£
276 ¤³¤ÎÀ©¸Â¤Ë¤è¤Ã¤Æ½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
277 ¤â¤·½½Ê¬¤Ê¥¹¥Ú¡¼¥¹¤¬¤¢¤ì¤Ð½ñ¤¹þ¤Þ¤ì¤¿¤Ç¤¢¤í¤¦Ê¸»ú¤Î¸Ä¿ô
278 (ʸ»úÎó¤ò½ªÃ¼¤¹¤ë NULL ¥Ð¥¤¥È¤ò½ü¤¯) ¤òÊÖ¤¹¡£
281 °Ê¾å¤À¤Ã¤¿¾ì¹ç¡¢½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¤³¤È¤ò°ÕÌ£¤¹¤ë
282 (¸å½Ò¤ÎÃí°Õ¤â»²¾È¤Î¤³¤È)¡£
284 .\"O If an output error is encountered, a negative value is returned.
285 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢Éé¤Î¿ô¤òÊÖ¤¹¡£
286 .\"O .SS "Format of the format string"
287 .SS ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Î¥Õ¥©¡¼¥Þ¥Ã¥È
288 .\"O The format string is a character string, beginning and ending
289 .\"O in its initial shift state, if any.
290 ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Ïʸ»ú¤ÎÎó¤Ç¡¢
291 (¤â¤·¤¢¤ë¤Ê¤é) ½é´ü¥·¥Õ¥È¾õÂ֤ǻϤޤꡢ½é´ü¥·¥Õ¥È¾õÂ֤ǽª¤ï¤ë¡£
292 .\"O The format string is composed of zero or more directives: ordinary
295 .\"O which are copied unchanged to the output stream;
296 .\"O and conversion specifications, each of which results in fetching zero or
297 .\"O more subsequent arguments.
298 ¥Õ¥©¡¼¥Þ¥Ã¥ÈÍѤÎʸ»úÎó¤Ï 0 ¸Ä°Ê¾å¤ÎÌ¿Îá (directives) ¤Ë¤è¤Ã¤Æ¹½À®¤µ¤ì¤ë¡£
299 Ì¿Îá¤Ë¤Ï¡¢Ä̾ïʸ»ú¤ÈÊÑ´¹»ØÄê (conversion specifications) ¤¬¤¢¤ë¡£
302 °Ê³°¤Îʸ»ú¤Ç¡¢½ÐÎÏ¥¹¥È¥ê¡¼¥à¤Ë¤½¤Î¤Þ¤Þ¥³¥Ô¡¼¤µ¤ì¤ë¡£
303 ÊÑ´¹»ØÄê¤Ï¡¢¤½¤ì¤¾¤ì¤¬ 0 ¸Ä°Ê¾å¤Î°ú¤¿ô¤ò¼è¤ë¡£
304 .\"O Each conversion specification is introduced by
308 .\"O .IR "conversion specifier" .
312 .I "ÊÑ´¹»ØÄê»Ò (conversion specifier)"
314 .\"O In between there may be (in this order) zero or more
316 .\"O an optional minimum
317 .\"O .IR "field width" ,
321 .\"O .IR "length modifier" .
323 ¤ÈÊÑ´¹»ØÄê»Ò¤Î´Ö¤Ë¤Ï¡¢0 ¸Ä°Ê¾å¤Î
329 ¤ò (¤³¤Î½ç½ø¤Ç) ÃÖ¤¯¤³¤È¤¬¤Ç¤¤ë¡£
331 .\"O The arguments must correspond properly (after type promotion) with the
332 .\"O conversion specifier.
333 .\"O By default, the arguments are used in the order
334 .\"O given, where each \(aq*\(aq and each conversion specifier asks for the next
335 .\"O argument (and it is an error if insufficiently many arguments are given).
336 °ú¤¿ô¤Ï (·¿¤Î³Ê¾å¤²¤Î¸å¤Ï) ÊÑ´¹»ØÄê»Ò¤¬É½¤¹·¿¤ÈÀµ³Î¤ËÂбþ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
337 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢\(aq*\(aq ¤äÊÑ´¹»ØÄê»Ò¤¬½Ð¤Æ¤¯¤ëËè¤Ë¼¡¤Î°ú¤¿ô¤òÍ׵ᤵ¤ì¡¢
338 °ú¤¿ô¤Ï»ØÄꤵ¤ì¤¿½ç½ø¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤¯
339 (»ØÄꤵ¤ì¤¿°ú¤¿ô¤Î¸Ä¿ô¤¬ÉÔ½½Ê¬¤Ê¤é¥¨¥é¡¼¤È¤Ê¤ë)¡£
340 .\"O One can also specify explicitly which argument is taken,
341 .\"O at each place where an argument is required, by writing "%m$" instead
342 .\"O of \(aq%\(aq and "*m$" instead of \(aq*\(aq,
343 .\"O where the decimal integer m denotes
344 .\"O the position in the argument list of the desired argument, indexed starting
350 .\"O printf("%*d", width, num);
358 .\"O printf("%2$*1$d", width, num);
362 ¤Þ¤¿¡¢°ú¤¿ô¤¬É¬Íפʲսê¤Ç \(aq%\(aq ¤ÎÂå¤ï¤ê¤Ë "%m$"¡¢
363 \(aq*\(aq¤ÎÂå¤ï¤ê¤Ë "*m$" ¤È½ñ¤¯¤³¤È¤Ç¡¢
364 ÌÀ¼¨Åª¤Ë¤É¤Î°ú¤¿ô¤ò»ÈÍѤ¹¤ë¤«¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤¤ë¡£
365 ¤³¤³¤Ç 10¿Ê¤ÎÀ°¿ô m ¤Ï´õ˾¤Î°ú¤¿ô¤Î°ú¤¿ô¥ê¥¹¥È¤Ç¤Î°ÌÃÖ¤ò¼¨¤¹
366 (ºÇ½é¤Î°ú¤¿ô¤ÎÈֹ椬 1 ¤Ç¤¢¤ë)¡£
367 ½¾¤Ã¤Æ¡¢°Ê²¼¤ÎÆó¤Ä¤ÏÅù²Á¤Ç¤¢¤ë¡£
371 printf("%*d", width, num);
373 printf("%2$*1$d", width, num);
379 .\"O The second style allows repeated references to the
381 .\"O The C99 standard does not include the style using \(aq$\(aq,
382 .\"O which comes from the Single UNIX Specification.
383 .\"O If the style using
384 .\"O \(aq$\(aq is used, it must be used throughout for all conversions taking an
385 .\"O argument and all width and precision arguments, but it may be mixed
386 .\"O with "%%" formats which do not consume an argument.
388 .\"O gaps in the numbers of arguments specified using \(aq$\(aq; for example, if
389 .\"O arguments 1 and 3 are specified, argument 2 must also be specified
390 .\"O somewhere in the format string.
391 ÆóÈÖÌܤνñ¤Êý¤Ç¤ÏƱ¤¸°ú¤¿ô¤ò·«¤êÊÖ¤·»²¾È¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
392 C99 ɸ½à¤Ë¤Ï¡¢ Single UNIX Specification ͳÍè¤Î \(aq$\(aq ¤ò»È¤Ã¤¿½ñ¤Êý¤Ï´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
393 \(aq$\(aq ¤ò»È¤Ã¤¿¥¹¥¿¥¤¥ë¤ò»È¤¦¤È¡¢°ú¤¿ô¤ò¼è¤ëÊÑ´¹µÚ¤ÓÉý¤ÈÀºÅ٤ΰú¤¿ô¤ò
394 Á´¤Æ¤³¤Î¥¹¥¿¥¤¥ë¤Ç»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤¬¡¢
395 °ú¤¿ô¤ò¾ÃÈñ¤·¤Ê¤¤ "%%" ¥Õ¥©¡¼¥Þ¥Ã¥È¤Èº®¤¶¤Ã¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
396 \(aq$\(aq ¤Ç»ØÄꤵ¤ì¤ë°ú¤¿ô¤ÎÈÖ¹æ¤Ë¶õ¤¤¬¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
397 Î㤨¤Ð¡¢¤â¤·°ú¤¿ô 1 ¤È 3 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢°ú¤¿ô 2 ¤â¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¤Î¤É¤³¤«¤Ç
398 »ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
400 .\"O For some numeric conversion a radix character ("decimal point") or
401 .\"O thousands' grouping character is used.
402 .\"O The actual character used
405 .\"O part of the locale.
406 .\"O The POSIX locale
407 .\"O uses \(aq.\(aq as radix character, and does not have a grouping character.
408 ¿ôÃÍÊÑ´¹¤Ë¤Ï¾®¿ôÅÀ¤ä 1000 ñ°Ì¤Î¶èÀÚ¤êʸ»ú¤ò»È¤¦¤â¤Î¤â¤¢¤ë¡£
409 ¼ÂºÝ¤Ë¤É¤Îʸ»ú¤ò»È¤¦¤«¤Ï¥í¥±¡¼¥ë¤Î
412 POSIX ¥í¥±¡¼¥ë¤Ç¤Ï¾®¿ôÅÀ¤Ë \(aq.\(aq ¤òÍѤ¤¡¢
413 ¶èÀÚ¤êʸ»ú¤Ï»È¤ï¤Ê¤¤¡£
419 printf("%\(aq.2f", 1234567.89);
423 .\"O results in "1234567.89" in the POSIX locale, in "1234567,89" in the
424 .\"O nl_NL locale, and in "1.234.567,89" in the da_DK locale.
425 ¤Ï¡¢ POSIX ¥í¥±¡¼¥ë¤Ç¤Ï "1234567.89" ¡¢ nl_NL ¥í¥±¡¼¥ë¤Ç¤Ï "1234567,89"¡¢
426 da_DK ¥í¥±¡¼¥ë¤Ç¤Ï "1.234.567,89" ¤È¤Ê¤ë¡£
427 .\"O .SS "The flag characters"
429 .\"O The character % is followed by zero or more of the following flags:
430 % ʸ»ú¤Î¸å¤í¤Ë¤Ï 0 ¸Ä°Ê¾å¤Î¥Õ¥é¥°Ê¸»ú¤¬Â³¤¯¡£
433 .\"O The value should be converted to an "alternate form".
435 ÃͤϡÖÊ̤ηÁ¼°¡×¤ËÊÑ´¹¤µ¤ì¤ë¡£
438 .\"O conversions, the first character of the output string is made zero
439 .\"O (by prefixing a 0 if it was not zero already).
441 ÊÑ´¹¤Î¾ì¹ç¡¢(ÀèƬʸ»ú¤¬ 0 ¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤ËÀèƬ¤Ë 0 ¤òÄɲ乤뤳¤È¤Ç)
442 ½ÐÎÏʸ»úÎó¤ÎºÇ½é¤Îʸ»ú¤ò 0 ¤Ë¤¹¤ë¡£
447 .\"O conversions, a nonzero result has the string "0x" (or "0X" for
449 .\"O conversions) prepended to it.
453 ÊÑ´¹¤Î¾ì¹ç¡¢¿ôÃͤ¬ 0 ¤Ç¤Ê¤¤¤È¤¤Ë¤Ïʸ»úÎó "0x"
455 ÊÑ´¹¤Î¾ì¹ç¤Ë¤Ï "0X") ¤¬Á°¤ËÉÕÍ¿¤µ¤ì¤ë¡£
466 .\"O conversions, the result will always contain a decimal point, even if no
467 .\"O digits follow it (normally, a decimal point appears in the results of those
468 .\"O conversions only if a digit follows).
478 ÊÑ´¹¤Ç¤Ï¡¢ ¾®¿ôÅÀ¤Ë³¤¯¿ô»ú¤¬¤Ê¤¯¤Æ¤â¡¢
479 ½ÐÎϤˤϾï¤Ë¾®¿ôÅÀ¤¬´Þ¤Þ¤ì¤ë
480 (Ä̾ï¤Ï¡¢¾®¿ôÅÀ¤Î¸å¤Ë¿ô»ú¤¬Â³¤¯¾ì¹ç¤Ë¤Î¤ß¡¢
481 ¾®¿ôÅÀ¤¬É½¼¨¤µ¤ì¤ë)¡£
485 .\"O conversions, trailing zeros are not removed from the result as they would
490 ÊÑ´¹¤Î¾ì¹ç¡¢Â¾¤ÎÊÑ´¹¤È¤Ï°Û¤Ê¤ê¡¢ËöÈø¤Î¥¼¥í¤¬ÊÑ´¹·ë²Ì¤«¤éºï½ü¤µ¤ì¤Ê¤¤¡£
491 .\"O For other conversions, the result is undefined.
492 ¤½¤Î¾¤ÎÊÑ´¹¤Ç¤Ï¡¢·ë²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
495 .\"O The value should be zero padded.
512 .\"O conversions, the converted value is padded on the left with zeros rather
529 ÊÑ´¹¤Ç¤Ï¡¢ÊÑ´¹¤·¤¿Ãͤκ¸Â¦¤ò¶õÇòʸ»ú¤ÎÂå¤ï¤ê¤Ë¥¼¥í¤ÇËä¤á¤ë¡£
534 .\"O flags both appear, the
536 .\"O flag is ignored.
540 ¤¬Î¾Êý¤È¤â»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
543 .\"O If a precision is given with a numeric conversion
553 .\"O flag is ignored.
561 ¤ÈƱ»þ¤Ë»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
564 .\"O For other conversions, the behavior is undefined.
565 ¤½¤Î¾¤ÎÊÑ´¹¤Ç¤Ï¡¢Æ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
568 .\"O The converted value is to be left adjusted on the field boundary.
569 .\"O (The default is right justification.)
572 .\"O conversions, the converted value is padded on the right with blanks, rather
573 .\"O than on the left with blanks or zeros.
575 ÊÑ´¹Ãͤò¥Õ¥£¡¼¥ë¥É¶³¦¤Çº¸Â·¤¨¤Ë¤¹¤ë
576 (¥Ç¥Õ¥©¥ë¥È¤Ï±¦Â·¤¨¤Ç¤¢¤ë)¡£
578 ÊÑ´¹°Ê³°¤Ç¤Ï¡¢ÊÑ´¹¤µ¤ì¤¿ÃͤÏ
579 º¸Â¦¤Ç¤Ï¤Ê¤¯±¦Â¦¤ò¶õÇòʸ»ú¤ä¥¼¥í¤ÇËä¤á¤é¤ì¤ë¡£
583 .\"O if both are given.
587 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
593 .\"O (a space) A blank should be left before a positive number
594 .\"O (or empty string) produced by a signed conversion.
596 Éä¹æÉÕ¤ÊÑ´¹¤ÇÀ¸À®¤µ¤ì¤¿Àµ¤Î¿ô»ú¤ÎÁ°¤Ë¶õÇò (¤Þ¤¿¤Ï¶õʸ»úÎó) ¤¬ÃÖ¤«¤ì¤ë¡£
599 .\"O A sign (+ or \-) should always be placed before a number produced by a signed
601 .\"O By default a sign is used only for negative numbers.
604 .\"O overrides a space if both are used.
606 Éä¹æÉÕ¤ÊÑ´¹¤Ë¤è¤Ã¤Æ½ÐÎϤµ¤ì¤ë¿ô»ú¤ÎÁ°¤Ë¡¢¾ï¤ËÉä¹æ (+ ¤« \-) ¤¬ÃÖ¤«¤ì¤ë¡£
607 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢Éä¹æ¤ÏÉé¤Î¿ô»ú¤Î¾ì¹ç¤Î¤ßÉÕÍ¿¤µ¤ì¤ë¡£
610 ξÊý¤¬»È¤ï¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
614 .\"O The five flag characters above are defined in the C standard.
615 .\"O The SUSv2 specifies one further flag character.
616 ¾åµ¤Î 5 ¤Ä¤Î¥Õ¥é¥°¤Ï C ɸ½à¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
617 SUSv2 ¤Ç¤Ï¡¢¤µ¤é¤Ë¤â¤¦°ì¤Ä¥Õ¥é¥°Ê¸»ú¤¬µ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
620 .\"O For decimal conversion
628 .\"O the output is to be grouped with thousands' grouping characters
629 .\"O if the locale information indicates any.
630 .\"O Note that many versions of
632 .\"O cannot parse this option and will issue a warning.
643 ¤Ë¤ª¤¤¤Æ¡¢¥í¥±¡¼¥ë¾ðÊó¤Ë»ØÄ꤬¤¢¤ì¤Ð 1000 ñ°Ì¤Î¶èÀÚ¤êʸ»ú¤ò½ÐÎϤ¹¤ë¡£
645 ¤Î¿¤¯¤Î¥Ð¡¼¥¸¥ç¥ó¤Ï¡¢¤³¤Î¥ª¥×¥·¥ç¥ó¤ò²ò¼á¤¹¤ë¤³¤È¤¬¤Ç¤¤º¡¢
646 ·Ù¹ð¤ò½ÐÎϤ¹¤ë¤³¤È¤ËÃí°Õ¤»¤è¡£
647 %\(aqF ¤Ï SUSv2 ¤Ë¤Ï´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
649 .\"O glibc 2.2 adds one further flag character.
650 glibc 2.2 ¤Ç¤Ï¡¢¤µ¤é¤Ë°ì¤Ä¥Õ¥é¥°Ê¸»ú¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
653 .\"O For decimal integer conversion
657 .\"O the output uses the locale's alternative output digits, if any.
658 .\"O For example, since glibc 2.2.3 this will give Arabic-Indic digits
659 .\"O in the Persian ("fa_IR") locale.
660 .\"O .\" outdigits keyword in locale file
665 ¤Ë¤ª¤¤¤Æ¡¢¥í¥±¡¼¥ë¤ÎÂåÂؽÐÎÏ¿ô»ú¤¬¤¢¤ì¤Ð¡¢¤½¤ì¤òÍѤ¤¤Æ½ÐÎϤ¹¤ë¡£
666 Î㤨¤Ð¡¢ glibc 2.2.3 °Ê¹ß¤Ç¤Ï¡¢¥Ú¥ë¥·¥¢ ("fa_IR") ¥í¥±¡¼¥ë¤Ç
667 ¥¢¥é¥Ó¥¢¿ô»ú (Arabic-Indic digits) ¤ò½ÐÎϤǤ¤ë¡£
668 .\" ¥í¥±¡¼¥ë¥Õ¥¡¥¤¥ë¤Ë¤Ï outdigits ¤È¤¤¤¦¥¡¼¥ï¡¼¥É¤¬¤¢¤ë¡£
669 .\"O .SS "The field width"
671 .\"O An optional decimal digit string (with nonzero first digit) specifying
672 .\"O a minimum field width.
673 .\"O If the converted value has fewer characters
674 .\"O than the field width, it will be padded with spaces on the left
675 .\"O (or right, if the left-adjustment flag has been given).
676 ºÇ¾®¤Î¥Õ¥£¡¼¥ë¥ÉÉý¤ò»ØÄꤹ¤ë 10¿Ê¿ô¤Î¿ôÃÍʸ»úÎó (ʸ»úÎó¤ÎºÇ½é¤Îʸ»ú¤Ï
677 ¥¼¥í°Ê³°)¡£ËܹàÌܤϥª¥×¥·¥ç¥ó¤Ç¤¢¤ë¡£
678 ÊÑ´¹¤µ¤ì¤¿ÃͤÎʸ»ú¿ô¤¬¥Õ¥£¡¼¥ë¥ÉŤè¤ê¤â¾¯¤Ê¤¤¾ì¹ç¡¢
679 ¥Õ¥£¡¼¥ë¥É¤Îº¸Â¦¤ò¥¹¥Ú¡¼¥¹¤ÇËä¤á¤ë
680 (º¸Â·¤¨¤Î¥Õ¥é¥°¤¬¤¢¤ë¾ì¹ç¤Ï±¦Â¦¤òËä¤á¤ë)¡£
681 .\"O Instead of a decimal digit string one may write "*" or "*m$"
682 .\"O (for some decimal integer \fIm\fP) to specify that the field width
683 .\"O is given in the next argument, or in the \fIm\fP-th argument, respectively,
684 .\"O which must be of type
686 10¿Ê¿ô¤Îʸ»úÎó¤ÎÂå¤ï¤ê¤Ë "*" ¤ä "*m$" (\fIm\fP ¤Ï 10¿ÊÀ°¿ô) ¤ò½ñ¤¯¤³¤È¤â¤Ç¤¤ë¡£
687 "*" ¤È "*m$" ¤Ï¤½¤ì¤¾¤ì¡¢¼¡¤Î°ú¤¿ô¤È \fIm\fP ÈÖÌܤΰú¤¿ô¤ò¥Õ¥£¡¼¥ë¥ÉÉý¤È¤·¤Æ
688 »È¤¦¤³¤È¤ò»ØÄꤹ¤ë (¤³¤ì¤é¤Î°ú¤¿ô¤Ï
690 ·¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£
691 .\"O A negative field width is taken as a \(aq\-\(aq flag followed by a
692 .\"O positive field width.
693 ¥Õ¥£¡¼¥ë¥ÉÉý¤ËÉé¤Î¿ô¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
694 \(aq\-\(aq ¥Õ¥é¥°¤ÈÀµ¤Î¿ô¤Î¥Õ¥£¡¼¥ë¥ÉÉý¤È¤·¤Æ°·¤ï¤ì¤ë¡£
695 .\"O In no case does a nonexistent or small field width cause truncation of a
696 .\"O field; if the result of a conversion is wider than the field width, the
697 .\"O field is expanded to contain the conversion result.
698 ¥Õ¥£¡¼¥ë¥ÉÉý¤¬¾®¤µ¤«¤Ã¤¿¤ê»ØÄ꤬¤Ê¤«¤Ã¤¿¤ê¤·¤Æ¤â¡¢¥Õ¥£¡¼¥ë¥É¤¬ÀÚ¤êµÍ¤á¤é¤ì¤ë
699 ¤³¤È¤Ï¤Ê¤¤¡£¤â¤·ÊÑ´¹·ë²Ì¤¬¥Õ¥£¡¼¥ë¥ÉÉý¤è¤ê¤â¹¤«¤Ã¤¿¾ì¹ç¡¢
700 ¥Õ¥£¡¼¥ë¥É¤ÏÊÑ´¹·ë²Ì¤¬Æþ¤ëÉý¤Ë¹¤²¤é¤ì¤ë¡£
701 .\"O .SS "The precision"
703 .\"O An optional precision, in the form of a period (\(aq.\(aq) followed by an
704 .\"O optional decimal digit string.
705 ¥ª¥×¥·¥ç¥ó¤Ç¤¢¤ëÀºÅ٤ϡ¢¥Ô¥ê¥ª¥É (\(aq.\(aq) ¤È¤½¤ì¤Ë³¤¯10¿Ê¿ô¤È¤¤¤¦
706 ·Á¼°¤Ç»ØÄꤹ¤ë (10¿Ê¿ô¤Ï¥ª¥×¥·¥ç¥ó) ¡£
707 .\"O Instead of a decimal digit string one may write "*" or "*m$"
708 .\"O (for some decimal integer m) to specify that the precision
709 .\"O is given in the next argument, or in the m-th argument, respectively,
710 .\"O which must be of type
712 10¿Ê¿ô¤Îʸ»úÎó¤ÎÂå¤ï¤ê¤Ë "*" ¤ä "*m$" (m ¤Ï 10 ¿ÊÀ°¿ô)¤ò½ñ¤¯¤³¤È¤â¤Ç¤¤ë¡£
713 "*" ¤È "*m$" ¤Ï¤½¤ì¤¾¤ì¡¢¼¡¤Î°ú¤¿ô¤È m ÈÖÌܤΰú¤¿ô¤òÀºÅ٤Ȥ·¤Æ
714 »È¤¦¤³¤È¤ò»ØÄꤹ¤ë (¤³¤ì¤é¤Î°ú¤¿ô¤Ï
716 ·¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£
717 .\"O If the precision is given as just \(aq.\(aq, or the precision is negative,
718 .\"O the precision is taken to be zero.
719 ÀºÅ٤Ȥ·¤Æ \(aq.\(aq ¤À¤±¤¬»ØÄꤵ¤ì¤¿¤ê¡¢ÀºÅÙ¤¬Éé¤Î¿ô¤À¤Ã¤¿¾ì¹ç¡¢
720 ÀºÅ٤ϥ¼¥í¤È¤ß¤Ê¤µ¤ì¤ë¡£
721 .\"O This gives the minimum number of digits to appear for
729 .\"O conversions, the number of digits to appear after the radix character for
737 .\"O conversions, the maximum number of significant digits for
741 .\"O conversions, or the maximum number of characters to be printed from a
753 ÊÑ´¹¤Ç¤Ï¡¢É½¼¨¤µ¤ì¤ëºÇ¾®¤Î·å¿ô¤ò»ØÄꤹ¤ë¡£
760 ÊÑ´¹¤Ç¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ëɽ¼¨¤µ¤ì¤ë¿ô»ú¤Î·å¿ô¤ò»ØÄꤹ¤ë¡£
764 ÊÑ´¹¤Ç¤Ï¡¢Í¸ú¿ô»ú¤ÎºÇÂç·å¿ô¤ò»ØÄꤹ¤ë¡£
768 ÊÑ´¹¤Ç¤Ï¡¢Ê¸»úÎ󤫤é½ÐÎϤµ¤ì¤ëºÇÂçʸ»ú¿ô¤ò»ØÄꤹ¤ë¡£
769 .\"O .SS "The length modifier"
771 .\"O Here, "integer conversion" stands for
790 .\"O A following integer conversion corresponds to a
793 .\"O .I unsigned char
794 .\"O argument, or a following
796 .\"O conversion corresponds to a pointer to a
799 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
805 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
807 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
810 .\"O A following integer conversion corresponds to a
813 .\"O .I unsigned short int
814 .\"O argument, or a following
816 .\"O conversion corresponds to a pointer to a
819 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
822 .I unsigned short int
825 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
827 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
830 .\"O (ell) A following integer conversion corresponds to a
833 .\"O .I unsigned long int
834 .\"O argument, or a following
836 .\"O conversion corresponds to a pointer to a
837 .\"O .I long long int
838 .\"O argument, or a following
840 .\"O conversion corresponds to a
842 .\"O argument, or a following
844 .\"O conversion corresponds to a pointer to
848 ³ÆÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬¡¢
851 .IR "unsigned long int" ¡¢
862 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
867 .\"O A following integer conversion corresponds to a
868 .\"O .I long long int
870 .\"O .I unsigned long long int
871 .\"O argument, or a following
873 .\"O conversion corresponds to a pointer to a
877 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
880 .I unsigned long long int
883 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
885 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
898 .\"O conversion corresponds to a
909 ÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
912 .\"O (C99 allows %LF, but SUSv2 does not.)
913 (C99 ¤Ç¤Ï %LF ¤ò»È¤¦¤³¤È¤òǧ¤á¤Æ¤¤¤ë¤¬¡¢SUSv2 ¤Ç¤Ïǧ¤á¤é¤ì¤Æ¤¤¤Ê¤¤¡£)
916 .\"O ("quad". 4.4BSD and Linux libc5 only.
918 .\"O This is a synonym for
920 ("quad"¡£ 4.4BSD ¤È Linux libc5 ¤Î¤ß͸ú¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£)
925 .\"O A following integer conversion corresponds to an
930 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
937 .\"O A following integer conversion corresponds to a
942 .\"O (Linux libc5 has
944 .\"O with this meaning.
946 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
951 (Linux libc5 ¤Ç¤Ï¡¢¤³¤ì¤ò»ØÄꤹ¤ë¤Î¤Ë
953 ¤òÍѤ¤¤ë¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£)
956 .\"O A following integer conversion corresponds to a
959 À°¿ôÊÑ´¹¤ËÂбþ¤¹¤ë°ú¤¿ô¤¬
963 .\"O The SUSv2 only knows about the length modifiers
991 SUSv2 ¤ÇŤµ½¤¾þ»Ò¤È¤·¤Æ»ÈÍѤǤ¤ë¤Î¤Ï¡¢
1015 .\"O .SS "The conversion specifier"
1017 .\"O A character that specifies the type of conversion to be applied.
1018 ŬÍѤµ¤ì¤ëÊÑ´¹¤Î·¿¤ò»ØÄꤹ¤ëʸ»ú¡£
1020 .\"O The conversion specifiers and their meanings are:
1021 ÊÑ´¹»ØÄê»Ò¤È¤½¤Î°ÕÌ£¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1026 .\"O argument is converted to signed decimal notation.
1028 °ú¤¿ô¤òÉä¹æÉÕ¤ 10 ¿Êɽµ¤ËÊÑ´¹¤¹¤ë¡£
1029 .\"O The precision, if any, gives the minimum number of digits
1030 .\"O that must appear; if the converted value requires fewer digits, it is
1031 .\"O padded on the left with zeros.
1032 .\"O The default precision is 1.
1033 ÀºÅÙ»ØÄ꤬¤¢¤ì¤Ð¡¢ÀºÅ٤ǻØÄꤷ¤¿·å¿ô¤Ïɬ¤º½ÐÎϤµ¤ì¤ë¡£ÊÑ´¹¸å¤ÎÃͤ¬
1034 »ØÄꤵ¤ì¤¿·å¿ô¤Ë¤ê¤Ê¤¤¾ì¹ç¤Ï¡¢º¸Â¦¤¬ 0 ¤ÇËä¤á¤é¤ì¤ë¡£
1035 ¥Ç¥Õ¥©¥ë¥È¤ÎÀºÅÙ¤Ï 1 ¤Ç¤¢¤ë¡£
1036 .\"O When 0 is printed with an explicit precision 0, the output is empty.
1037 0 ¤òɽ¼¨¤·¤è¤¦¤È¤·¤¿»þ¤Ë¡¢ÌÀ¼¨Åª¤ËÀºÅ٤Ȥ·¤Æ 0 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤È¡¢
1038 ½ÐÎϤ϶õʸ»úÎó¤È¤Ê¤ë¡£
1040 .BR o ", " u ", " x ", " X
1042 .\"O .I "unsigned int"
1043 .\"O argument is converted to unsigned octal
1045 .\"O unsigned decimal
1047 .\"O or unsigned hexadecimal
1067 .\"O conversions; the letters
1080 .\"O The precision, if any, gives the minimum number of digits
1081 .\"O that must appear; if the converted value requires fewer digits, it is
1082 .\"O padded on the left with zeros.
1083 ÀºÅÙ»ØÄ꤬¤¢¤ì¤Ð¡¢ÀºÅ٤ǻØÄꤷ¤¿·å¿ô¤Ïɬ¤º½ÐÎϤµ¤ì¤ë¡£ÊÑ´¹¸å¤ÎÃͤ¬
1084 »ØÄꤵ¤ì¤¿·å¿ô¤Ë¤ê¤Ê¤¤¾ì¹ç¤Ï¡¢º¸Â¦¤¬ 0 ¤ÇËä¤á¤é¤ì¤ë¡£
1089 .\"O argument is rounded and converted in the style
1090 .\"O .if \w'\*(Pm'=0 .ds Pm \(+-
1091 .\"O .RB [\-]d \&. ddd e \\*(Pmdd
1092 .\"O where there is one digit before the decimal-point character and the number
1093 .\"O of digits after it is equal to the precision; if the precision is missing,
1094 .\"O it is taken as 6; if the precision is zero, no decimal-point character
1099 .if \w'\*(Pm'=0 .ds Pm \(+-
1100 .RB [\-]d \&. ddd e \\*(Pmdd
1102 ¾®¿ôÅÀ¤ÎÁ°¤Ë¤Ï°ì·å¤Î¿ô»ú¤¬¤¢¤ê¡¢¾®¿ôÅÀ°Ê²¼¤Î·å¿ô¤ÏÀºÅ٤ǻØÄꤵ¤ì¤¿
1103 ·å¿ô¤Ë¤Ê¤ë¡£ÀºÅ٤ϻØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç 6 ¤È¤ß¤Ê¤µ¤ì¤ë¡£
1104 ÀºÅÙ¤¬ 0 ¤Î¾ì¹ç¤Ë¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ïɽ¼¨¤µ¤ì¤Ê¤¤¡£
1106 .\"O conversion uses the letter
1110 .\"O to introduce the exponent.
1112 ÊÑ´¹¤Ç¤Ï¡¢»Ø¿ô¤òɽ¸½¤¹¤ë¤È¤¤Ë
1117 .\"O The exponent always contains at least two
1118 .\"O digits; if the value is zero, the exponent is 00.
1119 »Ø¿ôÉôʬ¤Ï¾¯¤Ê¤¯¤È¤â 2·åɽ¼¨¤µ¤ì¤ë¡£
1120 ¤Ä¤Þ¤ê¡¢»Ø¿ô¤ÎÃͤ¬ 0 ¤Î¾ì¹ç¤Ë¤Ï¡¢00 ¤Èɽ¼¨¤µ¤ì¤ë¡£
1125 .\"O argument is rounded and converted to decimal notation in the style
1126 .\"O .RB [\-]ddd \&. ddd,
1127 .\"O where the number of digits after the decimal-point character is equal to
1128 .\"O the precision specification.
1132 ¤Î·Á¤Î10¿Êɽ¸½¤ËÊÑ´¹¤¹¤ë¡£
1133 ¾®¿ôÅÀ¤Î¸å¤Î·å¿ô¤Ï¡¢ÀºÅ٤ǻØÄꤵ¤ì¤¿ÃͤȤʤ롣
1134 .\"O If the precision is missing, it is taken as
1135 .\"O 6; if the precision is explicitly zero, no decimal-point character appears.
1136 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï 6 ¤È¤·¤Æ°·¤ï¤ì¤ë¡£
1137 ÀºÅ٤Ȥ·¤ÆÌÀ¼¨Åª¤Ë 0 ¤¬»ØÄꤵ¤ì¤¿¤È¤¤Ë¤Ï¡¢¾®¿ôÅÀ°Ê²¼¤Ïɽ¼¨¤µ¤ì¤Ê¤¤¡£
1138 .\"O If a decimal point appears, at least one digit appears before it.
1139 ¾®¿ôÅÀ¤òɽ¼¨¤¹¤ëºÝ¤Ë¤Ï¡¢¾®¿ôÅÀ¤ÎÁ°¤Ë¾¯¤Ê¤¯¤È¤â°ì·å¤Ï¿ô»ú¤¬É½¼¨¤µ¤ì¤ë¡£
1141 .\"O (The SUSv2 does not know about
1143 .\"O and says that character string representations for infinity and NaN
1144 .\"O may be made available.
1145 .\"O The C99 standard specifies "[\-]inf" or "[\-]infinity"
1146 .\"O for infinity, and a string starting with "nan" for NaN, in the case of
1148 .\"O conversion, and "[\-]INF" or "[\-]INFINITY" or "NAN*" in the case of
1153 ¤Ïµ¬Äꤵ¤ì¤Æ¤ª¤é¤º¡¢Ìµ¸Â¤ä NaN ¤Ë´Ø¤¹¤ëʸ»úÎóɽ¸½¤ò
1154 ¹Ô¤Ã¤Æ¤â¤è¤¤¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
1157 ÊÑ´¹¤Ç¤Ï¡¢Ìµ¸Â¤Ï "[\-]inf" ¤« "[\-]infinity" ¤Èɽ¼¨¤·¡¢
1158 NaN ¤Ïʸ»úÎó¤ÎÀèƬ¤Ë `nan' ¤ò¤Ä¤±¤Æɽ¼¨¤¹¤ë¤è¤¦¤Ëµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
1160 ÊÑ´¹¤Î¾ì¹ç¤Ï "[\-]INF", "[\-]INFINITY", "NAN*" ¤Èɽ¼¨¤µ¤ì¤ë¡£)
1165 .\"O argument is converted in style
1187 .\"O The precision specifies the number of significant digits.
1188 ÀºÅÙ¤Ïɽ¼¨¤¹¤ë·å¿ô¤ò»ØÄꤹ¤ë¡£
1189 .\"O If the precision is missing, 6 digits are given; if the precision is zero,
1190 .\"O it is treated as 1.
1191 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Ê¤¤¾ì¹ç¤Ï¡¢6·å¤È¤ß¤Ê¤µ¤ì¤ë¡£
1192 ÀºÅÙ¤¬ 0 ¤Î¾ì¹ç¤Ï¡¢1·å¤È¤ß¤Ê¤µ¤ì¤ë¡£
1195 .\"O is used if the exponent from its conversion is less than \-4 or greater
1196 .\"O than or equal to the precision.
1197 ÊÑ´¹¤µ¤ì¤ëÃͤλؿô¤¬¡¢ \-4 ¤è¤ê¾®¤µ¤¤¤«¡¢ÀºÅٰʾå¤Î¾ì¹ç¤Ë¡¢
1200 .\"O Trailing zeros are removed from the
1201 .\"O fractional part of the result; a decimal point appears only if it is
1202 .\"O followed by at least one digit.
1203 ÊÑ´¹¤µ¤ì¤¿·ë²Ì¤Î¾®¿ôÉôʬ¤ÎËöÈø¤Î 0 ¤Ïºï½ü¤µ¤ì¤ë¡£¾®¿ôÅÀ¤¬É½¼¨¤µ¤ì¤ë¤Î¤Ï¡¢
1204 ¾®¿ôÅÀ°Ê²¼¤Ë¿ô»ú¤¬¾¯¤Ê¤¯¤È¤â°ì¤Ä¤¢¤ë¾ì¹ç¤Ë¤À¤±¤Ç¤¢¤ë¡£
1207 .\"O (C99; not in SUSv2) For
1209 .\"O conversion, the
1211 .\"O argument is converted to hexadecimal notation (using the letters abcdef)
1213 .\"O .RB [\-] 0x h \&. hhhh p \\*(Pmd;
1216 .\"O conversion the prefix
1218 .\"O the letters ABCDEF, and the exponent separator
1221 (C99 ¤Ë¤Ï¤¢¤ë¤¬ SUSv2 ¤Ë¤Ï¤Ê¤¤)
1225 °ú¤¿ô¤ò (abcdef ¤Îʸ»ú¤ò»È¤Ã¤Æ)
1226 .RB [\-] 0x h \&. hhhh p \\*(Pmd;
1227 ·Á¼°¤Î 16 ¿Êɽµ¤ËÊÑ´¹¤¹¤ë¡£
1229 ÊÑ´¹¤Ç¤Ï¡¢Á°ÃÖʸ»úÎó
1231 ʸ»ú ABCDEF, »Ø¿ôʸ»ú
1234 .\"O There is one hexadecimal digit before the decimal point,
1235 .\"O and the number of digits after it is equal to the precision.
1236 ¾®¿ôÅÀ¤ÎÁ°¤Ë¤Ï 1·å¤Î16¿Ê¿ô¤¬ÃÖ¤«¤ì¡¢¾®¿ôÅÀ¤Î¸å¤í¤Î·å¿ô¤Ï
1237 ÀºÅ٤ǻØÄꤵ¤ì¤¿ÃͤȤʤ롣
1238 .\"O The default precision suffices for an exact representation of the value
1239 .\"O if an exact representation in base 2 exists
1240 .\"O and otherwise is sufficiently large to distinguish values of type
1242 ¥Ç¥Õ¥©¥ë¥È¤ÎÀºÅ٤ϡ¢¤½¤ÎÃͤ¬ 2¿Ê¿ô¤ÇÀµ³Î¤Ëɽ¸½¤Ç¤¤ë¾ì¹ç¤Ë¤Ï¡¢
1243 ¤½¤ÎÃͤòÀµ³Î¤Ëɽ¸½¤Ç¤¤ë·å¿ô¤È¤Ê¤ë¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢
1245 ·¿¤ÎÃͤò¶èÊ̤¹¤ë¤Î¤Ë½½Ê¬¤ÊÂ礤µ¤È¤Ê¤ë¡£
1246 .\"O The digit before the decimal point is unspecified for nonnormalized
1247 .\"O numbers, and nonzero but otherwise unspecified for normalized numbers.
1248 .\" motoki 2005/03/19: ¹ç¤Ã¤Æ¤¤¤ë¤«¤Ê¡©
1249 ¾®¿ôÅÀ¤ÎÁ°¤Î¿ô»ú¤Ï¡¢Àµµ¬²½¤µ¤ì¤Æ¤¤¤Ê¤¤¿ô¤Î¾ì¹ç¤Ï¤¤¤¯¤Ä¤Ë¤Ê¤ë¤«Ê¬¤«¤é¤Ê¤¤¡£
1250 Àµµ¬²½¤µ¤ì¤¿¿ô¤Î¾ì¹ç¤Ï¡¢ 0 °Ê³°¤ÎÃͤˤʤ뤬¡¢¤¤¤¯¤Ä¤Ë¤Ê¤ë¤«¤Ïʬ¤«¤é¤Ê¤¤¡£
1255 .\"O modifier is present, the
1257 .\"O argument is converted to an
1258 .\"O .IR "unsigned char" ,
1259 .\"O and the resulting character is written.
1265 ¤ËÊÑ´¹¤·¤Æ¡¢¤½¤Î·ë²Ì¤ËÂбþ¤¹¤ëʸ»ú¤ò½ÐÎϤ¹¤ë¡£
1268 .\"O modifier is present, the
1270 .\"O (wide character) argument is converted to a multibyte sequence by a call
1272 .\"O .BR wcrtomb (3)
1273 .\"O function, with a conversion state starting in the initial state, and the
1274 .\"O resulting multibyte string is written.
1278 (¥ï¥¤¥Éʸ»ú) °ú¤¿ô¤ò¡¢
1280 ´Ø¿ô¤ò½é´ü¥·¥Õ¥È¾õÂ֤ǸƤӽФ·¤Æ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ËÊÑ´¹¤·¡¢
1281 ÊÑ´¹¤µ¤ì¤¿¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò½ÐÎϤ¹¤ë¡£
1286 .\"O modifier is present: The
1287 .\"O .I "const char *"
1288 .\"O argument is expected to be a pointer to an array of character type (pointer
1290 .\"O Characters from the array are written up to (but not
1291 .\"O including) a terminating null byte (\(aq\\0\(aq);
1292 .\"O if a precision is specified, no more than the number specified
1294 .\"O If a precision is given, no null byte need be present;
1295 .\"O if the precision is not specified, or is greater than the size of the
1296 .\"O array, the array must contain a terminating null byte.
1301 ·¿¤Çʸ»ú·¿¤ÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ (ʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿) ¤Ç¤¢¤ë¤³¤È¤¬
1302 ´üÂÔ¤µ¤ì¤Æ¤¤¤ë¡£ÇÛÎóÃæ¤Îʸ»ú¤Ï¡¢½ªÃ¼¤Î NULL ¥Ð¥¤¥È (\(aq\\0\(aq)
1303 ¤¬½Ð¤Æ¤¯¤ë¤Þ¤Ç½ÐÎϤµ¤ì¤ë (½ªÃ¼Ê¸»ú¤Ï½ÐÎϤµ¤ì¤Ê¤¤)¡£
1304 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤È¡¢»ØÄꤵ¤ì¤¿»ú¿ô°Ê¾å¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£
1305 ÀºÅÙ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢½ªÃ¼¥Ð¥¤¥È¤¬Â¸ºß¤¹¤ëɬÍפϤʤ¤¡£
1306 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¤ê¡¢ÀºÅÙ¤ÎÃͤ¬ÇÛÎó¤ÎÂ礤µ¤è¤êÂ礤¤¾ì¹ç¤Ë¤Ï¡¢
1307 ÇÛÎó¤Ï½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤ò´Þ¤ó¤Ç¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1311 .\"O modifier is present: The
1312 .\"O .I "const wchar_t *"
1313 .\"O argument is expected to be a pointer to an array of wide characters.
1315 ½¤¾þ»Ò¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
1317 .I "const wchar_t *"
1318 ·¿¤Ç¥ï¥¤¥Éʸ»ú¤ÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤ë¡£
1319 .\"O Wide characters from the array are converted to multibyte characters
1320 .\"O (each by a call to the
1321 .\"O .BR wcrtomb (3)
1322 .\"O function, with a conversion state starting in the initial state before
1323 .\"O the first wide character), up to and including a terminating null
1324 .\"O wide character.
1325 .\"O The resulting multibyte characters are written up to
1326 .\"O (but not including) the terminating null byte.
1327 .\"O If a precision is
1328 .\"O specified, no more bytes than the number specified are written, but
1329 .\"O no partial multibyte characters are written.
1330 .\"O Note that the precision
1331 .\"O determines the number of
1333 .\"O written, not the number of
1334 .\"O .I wide characters
1336 .\"O .IR "screen positions" .
1337 ÇÛÎóÃæ¤Î¥ï¥¤¥Éʸ»ú¤Ï (1ʸ»úËè¤Ë
1339 ¤ò¸Æ¤Ó½Ð¤·¤Æ) ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤ËÊÑ´¹¤µ¤ì¤ë
1340 (ºÇ½é¤Î¥ï¥¤¥Éʸ»ú¤ÎÊÑ´¹¤ÎÁ°¤Ë
1342 ¤Î¥·¥Õ¥È¾õÂÖ¤ò½é´ü¾õÂÖ¤ËÌᤷ¤Æ¤«¤éÊÑ´¹¤Ï¹Ô¤ï¤ì¤ë)¡£
1343 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤Ø¤ÎÊÑ´¹¤Ï¡¢Ê¸»úÎó¤ò½ªÃ¼¤¹¤ë NULL ¥ï¥¤¥Éʸ»ú¤¬
1344 ½Ð¤Æ¤¯¤ë¤Þ¤Ç¹Ô¤ï¤ì¡¢½ªÃ¼ NULL ¥ï¥¤¥Éʸ»ú¤â´Þ¤á¤ÆÊÑ´¹¤µ¤ì¤ë¡£
1345 ·ë²Ì¤Î¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤Ï¡¢½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤¬½Ð¤Æ¤¯¤ë¤Þ¤Ç
1346 ½ÐÎϤµ¤ì¤ë (½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Ï½ÐÎϤµ¤ì¤Ê¤¤)¡£
1347 ÀºÅÙ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢»ØÄꤵ¤ì¤¿¥Ð¥¤¥È¿ô°Ê¾å¤Ë¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£
1348 ⤷¡¢¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤Î°ìÉôʬ¤À¤±¤¬½ÐÎϤµ¤ì¤ë¤³¤È¤Ï¤Ê¤¤¡£
1349 ÀºÅ٤ϡ֥Х¤¥È¡×¿ô¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¤¢¤ê¡¢¡Ö¥ï¥¤¥Éʸ»ú¡×¿ô¤ä
1350 ¡Ö²èÌ̤ǤΰÌÃ֡פò»ØÄꤹ¤ë¤â¤Î¤Ç¤Ï¤Ê¤¤¤³¤È¤ËÃí°Õ¡£
1351 .\"O The array must contain a terminating null wide character, unless a
1352 .\"O precision is given and it is so small that the number of bytes written
1353 .\"O exceeds it before the end of the array is reached.
1354 ÀºÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢¤µ¤é¤Ë½ÐÎϤ¬ÇÛÎó¤ÎËöÈø¤Ë㤹¤ëÁ°¤Ë½ÐÎϥХ¤¥È¿ô¤¬
1355 ÀºÅÙ¤ÎÃͤòĶ¤¨¤ë¾ì¹ç¤À¤±¤Ï¡¢ÇÛÎó¤Ï NULL ¥ï¥¤¥Éʸ»ú¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤¯¤Æ¤â¤è¤¤¡£
1356 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢É¬¤ºÇÛÎó¤Ï NULL ¥ï¥¤¥Éʸ»ú¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1359 .\"O (Not in C99, but in SUSv2.)
1363 (C99 ¤Ë¤Ï¤Ê¤¤¤¬ SUSv2 ¤Ë¤Ï¤¢¤ë)
1365 ¤ÈƱ¤¸¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1368 .\"O (Not in C99, but in SUSv2.)
1372 (C99 ¤Ë¤Ï¤Ê¤¤¤¬ SUSv2 ¤Ë¤Ï¤¢¤ë)
1374 ¤ÈƱ¤¸¡£»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1379 .\"O pointer argument is printed in hexadecimal (as if by
1388 ¤Î¤è¤¦¤Ê) 16 ¿Ê¿ô¤Ç½ÐÎϤ¹¤ë¡£
1391 .\"O The number of characters written so far is stored into the integer
1392 .\"O indicated by the
1394 .\"O (or variant) pointer argument.
1395 .\"O No argument is converted.
1396 ¤³¤ì¤Þ¤Ç¤Ë½ÐÎϤµ¤ì¤¿Ê¸»ú¿ô¤ò
1398 (¤Þ¤¿¤ÏÎà»÷¤Î·¿) ¤Î¥Ý¥¤¥ó¥¿°ú¤¿ô¤¬»Ø¤¹À°¿ô¤ËÊݸ¤¹¤ë¡£
1399 °ú¤¿ô¤ÎÊÑ´¹¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
1402 .\"O (Glibc extension.)
1403 .\"O Print output of
1404 .\"O .IR strerror(errno) .
1405 .\"O No argument is required.
1408 ¤Î½ÐÎϤòɽ¼¨¤¹¤ë¡£°ú¤¿ô¤ÏɬÍפʤ¤¡£
1411 .\"O A \(aq%\(aq is written.
1412 .\"O No argument is converted.
1413 .\"O The complete conversion
1414 .\"O specification is \(aq%%\(aq.
1415 \(aq%\(aq ʸ»ú¤ò½ÐÎϤ¹¤ë¡£ÊÑ´¹¤µ¤ì¤ë°ú¤¿ô¤Ï̵¤¤¡£
1416 ÊÑ´¹»ØÄêÁ´ÂΤò½ñ¤¯¤È "%%" ¤È¤Ê¤ë¡£
1417 .\"O .SH "CONFORMING TO"
1420 .\"O .BR fprintf (),
1422 .\"O .BR sprintf (),
1423 .\"O .BR vprintf (),
1424 .\"O .BR vfprintf (),
1426 .\"O .BR vsprintf ()
1427 .\"O functions conform to C89 and C99.
1434 ´Ø¿ô¤Ï¡¢C89 ¤È C99 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
1436 .\"O .BR snprintf ()
1438 .\"O .BR vsnprintf ()
1439 .\"O functions conform to C99.
1443 ¤Ï C99 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
1445 .\"O Concerning the return value of
1446 .\"O .BR snprintf (),
1447 .\"O SUSv2 and C99 standard contradict each other: when
1448 .\"O .BR snprintf ()
1451 .\"O then SUSv2 stipulates an unspecified return value less than 1,
1452 .\"O while C99 allows
1454 .\"O to be NULL in this case, and gives the return value (as always)
1455 .\"O as the number of characters that would have been written in case
1456 .\"O the output string has been large enough.
1459 SUSv2 ¤È C99 ɸ½à¤Ï¸ß¤¤¤ËÌ·½â¤·¤Æ¤¤¤ë¡£
1464 ¤Ç¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢ 1 ̤Ëþ¤ÎÃͤò²¿¤«ÊÖ¤êÃͤȤ¹¤ë¤è¤¦¤Ëµ¬Äꤷ¤Æ¤¤¤ë¡£
1465 °ìÊý C99 ¤Ç¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾ì¹ç
1467 ¤ò NULL ¤È¤·¡¢ÊÖ¤êÃͤȤ·¤Æ (Ä̾ïÄ̤ê) ½ÐÎϥХåե¡¤¬½½Ê¬¤ÊÂ礤µ¤¬
1468 ¤¢¤Ã¤¿¾ì¹ç¤Ë½ÐÎϤµ¤ì¤ë¤Ç¤¢¤í¤¦Ê¸»ú¿ô¤òÊÖ¤¹¡£
1470 .\"O Linux libc4 knows about the five C standard flags.
1471 .\"O It knows about the length modifiers \fBh\fP, \fBl\fP, \fBL\fP,
1472 .\"O and the conversions
1473 .\"O \fBc\fP, \fBd\fP, \fBe\fP, \fBE\fP, \fBf\fP, \fBF\fP,
1474 .\"O \fBg\fP, \fBG\fP, \fBi\fP, \fBn\fP, \fBo\fP, \fBp\fP,
1475 .\"O \fBs\fP, \fBu\fP, \fBx\fP, and \fBX\fP,
1476 .\"O where \fBF\fP is a synonym for \fBf\fP.
1477 Linux libc4 ¤Ç¤Ï¡¢ 5 ¤Ä¤Î C ɸ½à¤Î¥Õ¥é¥°¡¢
1478 Ťµ½¤¾þ»Ò \fBh\fP, \fBl\fP, \fBL\fP¡¢ÊÑ´¹
1479 \fBc\fP, \fBd\fP, \fBe\fP, \fBE\fP, \fBf\fP, \fBF\fP,
1480 \fBg\fP, \fBG\fP, \fBi\fP, \fBn\fP, \fBo\fP, \fBp\fP,
1481 \fBs\fP, \fBu\fP, \fBx\fP, \fBX\fP
1483 ⤷ \fBF\fP ¤Ï \fBf\fP ¤ÈƱµÁ¤Ç¤¢¤ë¡£
1484 .\"O Additionally, it accepts \fBD\fP, \fBO\fP, and \fBU\fP as synonyms
1485 .\"O for \fBld\fP, \fBlo\fP, and \fBlu\fP.
1486 .\"O (This is bad, and caused serious bugs later, when
1487 .\"O support for \fB%D\fP disappeared.)
1488 .\"O No locale-dependent radix character,
1489 .\"O no thousands' separator, no NaN or infinity, no "%m$" and "*m$".
1490 ¤Þ¤¿¡¢ \fBD\fP, \fBO\fP, and \fBU\fP ¤ò \fBld\fP, \fBlo\fP, and \fBlu\fP
1491 ¤ÈƱ¤¸¤â¤Î¤È¤·¤Æ»È¤¨¤ë
1492 (¤³¤ì¤Ï¤Þ¤º¤¤»ÅÍͤǡ¢ ¸å¤Ë \fB%D\fP ¤ÎÂбþ¤¬ÂǤÁÀÚ¤é¤ì¤¿»þ¤Ë¿¼¹ï¤Ê¥Ð¥°¤ò
1493 °ú¤µ¯¤³¤·¤¿)¡£¥í¥±¡¼¥ë°Í¸¤Î¾®¿ôÅÀ¡¢1000 ¶èÀڤꡢ NaN ¤È̵¸Â¡¢
1494 "%m$" ¤È "*m$" ¤Ï»È¤¨¤Ê¤¤¡£
1496 .\"O Linux libc5 knows about the five C standard flags and the \(aq flag,
1497 .\"O locale, "%m$" and "*m$".
1498 .\"O It knows about the length modifiers \fBh\fP, \fBl\fP, \fBL\fP,
1499 .\"O \fBZ\fP, and \fBq\fP, but accepts \fBL\fP and \fBq\fP
1500 .\"O both for \fIlong double\fP and for \fIlong long int\fP (this is a bug).
1501 Linux libc5 ¤Ç¤Ï¡¢ 5 ¤Ä¤Î C ɸ½à¤Î¥Õ¥é¥°¤È \(aq ¥Õ¥é¥°¡¢¥í¥±¡¼¥ë¡¢
1502 "%m$" ¤È "*m$" ¤¬»È¤¨¤ë¡£
1503 ¤Þ¤¿¡¢Ä¹¤µ½¤¾þ»Ò \fBh\fP, \fBl\fP, \fBL\fP, \fBZ\fP, iand \fBq\fP ¤¬»È¤¨¤ë¤¬¡¢
1504 \fBL\fP ¤È \fBq\fP ¤ÏξÊý¤È¤â
1505 \fIlong double\fP ¤È \fIlong long int\fP ¤ËÂбþ¤·¤Æ¤¤¤ë (¤³¤ì¤Ï¥Ð¥°¤Ç¤¢¤ë)¡£
1506 .\"O It no longer recognizes \fBF\fP, \fBD\fP, \fBO\fP, and \fBU\fP,
1507 .\"O but adds the conversion character
1510 .\"O .IR strerror(errno) .
1511 ¸½ºß¤Ç¤ÏÊÑ´¹ \fBF\fP, \fBD\fP, \fBO\fP, \fBU\fP ¤Ïǧ¼±¤µ¤ì¤Ê¤¤¤¬¡¢ÊÑ´¹Ê¸»ú
1513 ¤¬Äɲ䵤줿¡£¤³¤ì¤Ï
1515 ¤ò½ÐÎϤ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
1517 .\"O glibc 2.0 adds conversion characters \fBC\fP and \fBS\fP.
1518 glibc 2.0 ¤Ç¤Ï¡¢ÊÑ´¹Ê¸»ú \fBC\fP ¤È \fBS\fP ¤¬Äɲ䵤줿¡£
1520 .\"O glibc 2.1 adds length modifiers \fBhh\fP, \fBj\fP, \fBt\fP, and \fBz\fP
1521 .\"O and conversion characters \fBa\fP and \fBA\fP.
1522 glibc 2.1 ¤Ç¤Ï¡¢Ä¹¤µ½¤¾þ»Ò \fBhh\fP, \fBj\fP, \fBt\fP, \fBz\fP
1523 ¤ÈÊÑ´¹Ê¸»ú \fBa\fP, \fBA\fP ¤¬Äɲ䵤줿¡£
1525 .\"O glibc 2.2 adds the conversion character \fBF\fP with C99 semantics,
1526 .\"O and the flag character \fBI\fP.
1527 glibc 2.2 ¤Ç¤Ï¡¢ C99 ¤Çµ¬Äꤵ¤ì¤¿°ÕÌ£¤Ç¤ÎÊÑ´¹Ê¸»ú \fBF\fP ¤È
1528 ¥Õ¥é¥°Ê¸»ú \fBI\fP ¤¬Äɲ䵤줿¡£
1531 .\"O Some programs imprudently rely on code such as the following
1533 .\"O sprintf(buf, "%s some further text", buf);
1535 .\"O to append text to
1539 ¤ËÄɲ乤ë¤Î¤Ë¡¢·ÚΨ¤Ë¤â¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤Ã¤Æ¤¤¤ë¥×¥í¥°¥é¥à¤¬¤¢¤ë¡£
1541 sprintf(buf, "%s some further text", buf);
1543 .\"O However, the standards explicitly note that the results are undefined
1544 .\"O if source and destination buffers overlap when calling
1545 .\"O .BR sprintf (),
1546 .\"O .BR snprintf (),
1547 .\"O .BR vsprintf (),
1549 .\"O .BR vsnprintf ().
1550 ¤·¤«¤·¤Ê¤¬¤é¡¢É¸½àµ¬³Ê¤Ç¤Ï¡¢
1555 ¤Î¸Æ¤Ó½Ð¤·¤Ë¤ª¤¤¤Æ¡¢¥³¥Ô¡¼¸µ¤È¥³¥Ô¡¼Àè¤Î¥Ð¥Ã¥Õ¥¡¤¬½Å¤Ê¤Ã¤Æ¤¤¤¿¾ì¹ç¤Î
1556 ·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¡¢¤ÈÌÀµ¤µ¤ì¤Æ¤¤¤ë¡£
1557 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7075
1558 .\"O Depending on the version of
1560 .\"O used, and the compiler options employed, calls such as the above will
1562 .\"O produce the expected results.
1565 ¤Î¥Ð¡¼¥¸¥ç¥ó¤ä»ØÄꤷ¤¿¥³¥ó¥Ñ¥¤¥é¤Î¥ª¥×¥·¥ç¥ó¼¡Âè¤Ç¤Ï¡¢
1566 ¾åµ¤Î¤è¤¦¤Ê¸Æ¤Ó½Ð¤·¤Ç¡¢´üÂÔ¤·¤¿·ë²Ì¤¬ÆÀ¤é¤ì¡Ö¤Ê¤¤¡×¤³¤È¤¬¤¢¤ë¡£
1568 .\"O The glibc implementation of the functions
1569 .\"O .BR snprintf ()
1571 .\"O .BR vsnprintf ()
1572 .\"O conforms to the C99 standard, that is, behaves as described above,
1573 .\"O since glibc version 2.1.
1574 .\"O Until glibc 2.0.6 they would return \-1
1575 .\"O when the output was truncated.
1580 ¤Î¼ÂÁõ¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Ï C99 ɸ½à¤Ë½àµò¤·¤Æ¤ª¤ê¡¢
1581 ¾åµ¤ÎÄ̤ê¤ÎÆ°ºî¤ò¤¹¤ë¡£
1582 glibc 2.0.6 ¤Þ¤Ç¤Ï¡¢½ÐÎϤ¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
1583 .\"O .\" .SH HISTORY
1585 .\"O .\" UNIX V7 defines the three routines
1586 .\"O .\" .BR printf (),
1587 .\"O .\" .BR fprintf (),
1588 .\"O .\" .BR sprintf (),
1589 .\"O .\" and has the flag \-, the width or precision *, the length modifier l,
1590 .\"O .\" and the conversions doxfegcsu, and also D,O,U,X as synonyms for ld,lo,lu,lx.
1595 .\" ¤Î 3 ¤Ä¤Î´Ø¿ô¤È¡¢¥Õ¥é¥° \-¡¢Éý¤ÈÀºÅ٤ǤΠ*¡¢Ä¹¤µ½¤¾þ»Ò l¡¢
1596 .\" ÊÑ´¹ doxfegcsu¡¢¤½¤·¤Æ ld,ld,lu,lx ¤ÎƱµÁ¸ì¤È¤·¤Æ D,O,U,X ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
1597 .\"O .\" This is still true for 2.9.1BSD, but 2.10BSD has the flags
1598 .\"O .\" #, + and <space> and no longer mentions D,O,U,X.
1599 .\" 2.9.1BSD ¤Ç¤â¤³¤ì¤ÏƱ¤¸¤À¤Ã¤¿¤¬¡¢ 2.10BSD ¤Ç¤Ï
1600 .\" ¥Õ¥é¥° #, +, ¶õÇò¤¬Äɲ䵤졢 D,O,U,X ¤Ë¤Ä¤¤¤Æ¤ÏµºÜ¤µ¤ì¤Ê¤¯¤Ê¤Ã¤¿¡£
1601 .\"O .\" 2.11BSD has
1602 .\"O .\" .BR vprintf (),
1603 .\"O .\" .BR vfprintf (),
1604 .\"O .\" .BR vsprintf (),
1605 .\"O .\" and warns not to use D,O,U,X.
1608 .\" .BR vfprintf (),
1610 .\" ¤¬Äɲ䵤졢 D,O,U,X ¤ò»È¤ï¤Ê¤¤¤è¤¦¤Ë·Ù¹ð¤µ¤ì¤¿¡£
1611 .\"O .\" 4.3BSD Reno has the flag 0, the length modifiers h and L,
1612 .\"O .\" and the conversions n, p, E, G, X (with current meaning)
1613 .\"O .\" and deprecates D,O,U.
1614 .\" 4.3BSD Reno ¤Ç¤Ï¥Õ¥é¥° 0¡¢Ä¹¤µ½¤¾þ»Ò h ¤È L¡¢
1615 .\" ÊÑ´¹ n, p, E, G, (¸½ºß¤Î°ÕÌ£¤Ç¤Î) X ¤¬Äɲ䵤졢
1616 .\" D,O,U ¤ÏÈó¿ä¾©°·¤¤¤È¤Ê¤Ã¤¿¡£
1617 .\"O .\" 4.4BSD introduces the functions
1618 .\"O .\" .BR snprintf ()
1620 .\"O .\" .BR vsnprintf (),
1621 .\"O .\" and the length modifier q.
1622 .\" 4.4BSD ¤Ç¤Ï¡¢´Ø¿ô
1623 .\" .BR snprintf ()¤È
1624 .\" .BR vsnprintf ()¡¢
1625 .\" Ťµ½¤¾þ»Ò q ¤¬Æ³Æþ¤µ¤ì¤¿¡£
1626 .\"O .\" FreeBSD also has functions
1627 .\"O .\" .BR asprintf ()
1629 .\"O .\" .BR vasprintf (),
1630 .\"O .\" that allocate a buffer large enough for
1631 .\"O .\" .BR sprintf ().
1634 .\" ¤Î¤¿¤á¤Ë½½Ê¬¤Ê¥Ð¥Ã¥Õ¥¡¤ò³ÎÊݤ¹¤ë
1637 .\" .BR vasprintf ()
1638 .\" ¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
1639 .\"O .\" In glibc there are functions
1640 .\"O .\" .BR dprintf ()
1642 .\"O .\" .BR vdprintf ()
1643 .\"O .\" that print to a file descriptor instead of a stream.
1644 .\" glibc ¤Ë¤Ï¡¢´Ø¿ô
1647 .\" ¤¬¤¢¤ê¡¢¤³¤ì¤é¤Ï¥¹¥È¥ê¡¼¥à¤Ç¤Ï¤Ê¤¯¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë½ÐÎϤ¹¤ë¡£
1653 .\"O .BR vsprintf ()
1654 .\"O assume an arbitrarily long string, callers must be careful not to overflow
1655 .\"O the actual space; this is often impossible to assure.
1656 .\"O Note that the length
1657 .\"O of the strings produced is locale-dependent and difficult to predict.
1661 ¤Ï¾¡¼ê¤Ë½½Ê¬¤ËŤ¤Ê¸»úÎóÎΰ褬¤¢¤ë¤È²¾Äꤹ¤ë¤Î¤Ç¡¢¸Æ¤Ó½Ð¤·Â¦¤Ï
1662 ¼ÂºÝ¤ÎÎΰ褫¤é¤¢¤Õ¤ì¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1663 ¤·¤«¤·¡¢¤³¤ì¤òÊݾڤ¹¤ë¤³¤È¤¬ÉÔ²Äǽ¤Ê¾ì¹ç¤¬Â¿¤¤¡£
1664 À¸À®¤µ¤ì¤ëʸ»úÎó¤ÎŤµ¤Ï¥í¥±¡¼¥ë°Í¸¤Ç¤¢¤ê¡¢Í½Â¬¤¬Æñ¤·¤¤¤³¤È¤ËÃí°Õ¡£
1666 .\"O .BR snprintf ()
1668 .\"O .BR vsnprintf ()
1670 .\"O .BR asprintf (3)
1672 .\"O .BR vasprintf (3)).
1683 .\"O Linux libc4.[45] does not have a
1684 .\"O .BR snprintf (),
1685 .\"O but provides a libbsd that contains an
1686 .\"O .BR snprintf ()
1688 .\"O .BR sprintf (),
1689 .\"O that is, one that ignores the
1692 Linux libc4.[45] ¤Ë¤Ï
1694 ¤Ï¤Ê¤¤¤¬¡¢ libbsd ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢
1702 .\"O Thus, the use of
1703 .\"O .BR snprintf ()
1704 .\"O with early libc4 leads to serious security problems.
1705 ¤·¤¿¤¬¤Ã¤Æ¡¢½é´ü¤Î libc4 ¤Ç
1707 ¤ò»È¤¦¤È¡¢¿¼¹ï¤Ê¥»¥¥å¥ê¥Æ¥£ÌäÂê¤ò°ú¤µ¯¤³¤¹¤³¤È¤¬¤¢¤ë¡£
1710 .\"O .BI printf( foo );
1711 .\"O often indicates a bug, since
1713 .\"O may contain a % character.
1716 .\"O comes from untrusted user input, it may contain \fB%n\fP, causing the
1718 .\"O call to write to memory and creating a security hole.
1720 ¤Î¤è¤¦¤Ê¥³¡¼¥É¤Ï¤·¤Ð¤·¤Ð¥Ð¥°¤ò°ú¤µ¯¤³¤¹¡£
1723 ¤Ë % ʸ»ú¤¬´Þ¤Þ¤ì¤Æ¤ë¤«¤â¤·¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
1725 ¤¬¿®Íê¤Ç¤¤Ê¤¤¥æ¡¼¥¶¡¼ÆþÎϤ«¤éºî¤é¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
1726 ¤½¤ÎÃæ¤Ë \fB%n\fP ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ê¡¢
1728 ¸Æ¤Ó½Ð¤·»þ¤Ë¥á¥â¥ê¤Ø¤Î½ñ¤¹þ¤ß¤¬µ¯¤³¤ê¡¢
1729 ¥»¥¥å¥ê¥Æ¥£¡¼¥Û¡¼¥ë¤òºî¤ë¤³¤È¤Ë¤Ê¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1731 .\".\"O Some floating-point conversions under early libc4
1732 .\".\"O caused memory leaks.
1733 .\"½é´ü¤Î libc4 ¤Ç¤Î¼Â¿ôÊÑ´¹¤Ë¤Ï¥á¥â¥ê¥ê¡¼¥¯¤ò°ú¤µ¯¤³¤¹¤³¤È¤¬¤¢¤ë¡£
1736 .if \w'\*(Pi'=0 .ds Pi pi
1737 .\"O To print \*(Pi to five decimal places:
1738 \*(Pi ¤ò 5 ·å¤Ç½ÐÎϤ¹¤ë¡£
1744 fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0));
1748 .\"O To print a date and time in the form "Sunday, July 3, 10:02",
1753 .\"O are pointers to strings:
1754 ÆüÉդȻþ´Ö¤ò "Sunday, July 3, 10:02" ¤Î·Á¼°¤Ç½ÐÎϤ¹¤ë¡£
1758 ¤Ïʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë)
1763 fprintf(stdout, "%s, %s %d, %.2d:%.2d\en",
1764 weekday, month, day, hour, min);
1768 .\"O Many countries use the day-month-year order.
1769 .\"O Hence, an internationalized version must be able to print
1770 .\"O the arguments in an order specified by the format:
1771 Æü - ·î - ǯ ¤Î½ç½ø¤Çɽ¼¨¤ò¹Ô¤¦¹ñ¤â¿¤¤¡£
1772 ½¾¤Ã¤Æ¡¢¹ñºÝÈǤǤϽñ¼°¤Ç»ØÄꤵ¤ì¤¿½çÈÖ¤Ç
1773 °ú¤¿ô¤òɽ¼¨¤Ç¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1778 fprintf(stdout, format,
1779 weekday, month, day, hour, min);
1785 .\"O depends on locale, and may permute the arguments.
1786 .\"O With the value:
1788 ¤Ï¥í¥±¡¼¥ë¤Ë°Í¸¤·¤Æ¤ª¤ê¡¢°ú¤¿ô¤Î½çÈÖ¤òÊѤ¨¤ë¤³¤È¤â¤Ç¤¤ë¡£
1794 "%1$s, %3$d. %2$s, %4$d:%5$.2d\en"
1798 .\"O one might obtain "Sonntag, 3. Juli, 10:02".
1799 ¤Ç¤¢¤ì¤Ð¡¢ "Sonntag, 3. Juli, 10:02" ¤È¤¤¤¦·ë²Ì¤Ë¤Ê¤ë¡£
1801 .\"O To allocate a sufficiently large string and print into it
1802 .\"O (code correct for both glibc 2.0 and glibc 2.1):
1803 ½½Ê¬¤ËÂ礤Êʸ»úÎóÎΰè¤ò³ÎÊݤ·¤Æ¡¢¤½¤³¤Ë¥á¥Ã¥»¡¼¥¸¤ò³ÊǼ¤¹¤ë¤Ë¤Ï
1804 (glibc 2.0 ¤È glibc 2.1 ¤ÎξÊý¤ÇÀµ¤·¤¯Æ°ºî¤¹¤ë¥³¡¼¥É):
1811 make_message(const char *fmt, ...)
1814 int size = 100; /* Guess we need no more than 100 bytes. */
1818 if ((p = malloc(size)) == NULL)
1823 /* Try to print in the allocated space. */
1826 n = vsnprintf(p, size, fmt, ap);
1829 /* If that worked, return the string. */
1831 if (n > \-1 && n < size)
1834 /* Else try again with more space. */
1836 if (n > \-1) /* glibc 2.1 */
1837 size = n+1; /* precisely what is needed */
1838 else /* glibc 2.0 */
1839 size *= 2; /* twice the old size */
1841 if ((np = realloc (p, size)) == NULL) {