OSDN Git Service

d59648748f8416112734c01b7ebd5a7507f8b96a
[linuxjm/LDP_man-pages.git] / draft / man3 / scanf.3
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)scanf.3     6.14 (Berkeley) 1/8/93
37 .\"
38 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
39 .\" modified to resemble the GNU libio setup used in the Linux libc
40 .\" used in versions 4.x (x>4) and 5   Helmut.Geyer@iwr.uni-heidelberg.de
41 .\" Modified, aeb, 970121
42 .\" 2005-07-14, mtk, added description of %n$ form; various text
43 .\"     incorporated from the GNU C library documentation ((C) The
44 .\"     Free Software Foundation); other parts substantially rewritten.
45 .\"
46 .\" 2008-06-23, mtk
47 .\"     Add ERRORS section.
48 .\"     Document the 'a' and 'm' modifiers for dynamic string allocation.
49 .\"
50 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
51 .\"       all rights reserved.
52 .\" Translated 1998-02-17, YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
53 .\" Updated 2003-02-23, Kentaro Shirakata <argrath@ub32.org>
54 .\" Updated 2005-09-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
55 .\" Updated 2008-08-11, Akihiro MOTOKI, LDP v3.05
56 .\"
57 .\"WORD:        conversion specifications       ÊÑ´¹»ØÄê
58 .\"WORD:        type modifier                   ·¿½¤¾þ»Ò
59 .\"
60 .TH SCANF 3  2011-09-28 "GNU" "Linux Programmer's Manual"
61 .\"O .SH NAME
62 .SH Ì¾Á°
63 .\"O scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion
64 scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- ½ñ¼°ÉÕ¤­ÆþÎÏÊÑ´¹
65 .\"O .SH SYNOPSIS
66 .SH ½ñ¼°
67 .nf
68 .B #include <stdio.h>
69
70 .BI "int scanf(const char *" format ", ...);"
71 .BI "int fscanf(FILE *" stream ", const char *" format ", ...);"
72 .BI "int sscanf(const char *" str ", const char *" format ", ...);"
73 .sp
74 .B #include <stdarg.h>
75
76 .BI "int vscanf(const char *" format ", va_list " ap );
77 .BI "int vsscanf(const char *" str ", const char *" format ", va_list " ap );
78 .BI "int vfscanf(FILE *" stream ", const char *" format ", va_list " ap );
79 .fi
80 .sp
81 .in -4n
82 .\"O Feature Test Macro Requirements for glibc (see
83 .\"O .BR feature_test_macros (7)):
84 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
85 .RB ( feature_test_macros (7)
86 »²¾È):
87 .in
88 .ad l
89 .sp
90 .BR vscanf (),
91 .BR vsscanf (),
92 .BR vfscanf ():
93 .RS 4
94 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
95 _POSIX_C_SOURCE\ >=\ 200112L;
96 .br
97 or
98 .I "cc -std=c99"
99 .ad
100 .RE
101 .\"O .SH DESCRIPTION
102 .SH ÀâÌÀ
103 .\"O The
104 .\"O .BR scanf ()
105 .\"O family of functions scans input according to
106 .\"O .I format
107 .\"O as described below.
108 .\"O This format may contain
109 .\"O .IR "conversion specifications" ;
110 .\"O the results from such conversions, if any,
111 .\"O are stored in the locations pointed to by the
112 .\"O .I pointer
113 .\"O arguments that follow
114 .\"O .IR format .
115 .\"O Each
116 .\"O .I pointer
117 .\"O argument must be of a type that is appropriate for the value returned
118 .\"O by the corresponding conversion specification.
119 .BR scanf ()
120 ´Ø¿ô¥°¥ë¡¼¥×¤Ï¡¢°Ê²¼¤Ë½Ò¤Ù¤ë¤è¤¦¤Ë¡¢
121 .I format
122 ¤Ë½¾¤Ã¤ÆÆþÎϤòÆɤ߹þ¤à¤â¤Î¤Ç¤¢¤ë¡£
123 ¤³¤Î½ñ¼°¤Ë¤Ï
124 .I "¡ÖÊÑ´¹»ØÄê¡× (conversion specifications)"
125 ¤ò´Þ¤á¤ë¤³¤È¤¬¤Ç¤­¡¢ÊÑ´¹»ØÄ꤬¤¢¤ì¤Ð¡¢¤½¤ÎÊÑ´¹¤Î·ë²Ì¤Ï
126 .I format
127 ¤Ë³¤¯
128 .I pointer
129 °ú¤­¿ô¤¬»Ø¤¹¾ì½ê¤Ë³ÊǼ¤µ¤ì¤ë¡£
130 ¤½¤ì¤¾¤ì¤Î
131 .I pointer
132 °ú¤­¿ô¤Î·¿¤Ï¡¢Âбþ¤¹¤ëÊÑ´¹»ØÄ꤬ÊÖ¤¹ÃͤË
133 Ŭ¹ç¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
134
135 .\"O If the number of conversion specifications in
136 .\"O .I format
137 .\"O exceeds the number of
138 .\"O .I pointer
139 .\"O arguments, the results are undefined.
140 .\"O If the number of
141 .\"O .I pointer
142 .\"O arguments exceeds the number of conversion specifications, then the excess
143 .\"O .I pointer
144 .\"O arguments are evaluated, but are otherwise ignored.
145 .I format
146 Ãæ¤ÎÊÑ´¹»ØÄê¤Î¸Ä¿ô¤¬
147 .I pointer
148 °ú¤­¿ô¤Î¿ô¤è¤ê¿¤«¤Ã¤¿¾ì¹ç¤Î·ë²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
149 .I pointer
150 °ú¤­¿ô¤Î¿ô¤¬ÊÑ´¹»ØÄê¤Î¸Ä¿ô¤è¤ê¤â¿¤«¤Ã¤¿¾ì¹ç¡¢
151 ;ʬ¤Ê
152 .I pointer
153 °ú¤­¿ô¤Îɾ²Á¤Ï¹Ô¤ï¤ì¤ë¤¬¡¢¤½¤ì°Ê³°¤Ï¹Ô¤ï¤ì¤ºÌµ»ë¤µ¤ì¤ë¡£
154
155 .\"O The
156 .\"O .BR scanf ()
157 .\"O function reads input from the standard input stream
158 .\"O .IR stdin ,
159 .\"O .BR fscanf ()
160 .\"O reads input from the stream pointer
161 .\"O .IR stream ,
162 .\"O and
163 .\"O .BR sscanf ()
164 .\"O reads its input from the character string pointed to by
165 .\"O .IR str .
166 .BR scanf ()
167 ´Ø¿ô¤Ïɸ½àÆþÎÏ¥¹¥È¥ê¡¼¥à
168 .I stdin
169 ¤«¤é¤ÎÆþÎϤòÆɤ߹þ¤à¡£
170 .BR fscanf ()
171 ¤Ï¥¹¥È¥ê¡¼¥à¥Ý¥¤¥ó¥¿
172 .I stream
173 ¤«¤é¤ÎÆþÎϤòÆɤ߹þ¤à¡£
174 .BR sscanf ()
175 ¤Ïʸ»úÎó¥Ý¥¤¥ó¥¿
176 .I str
177 ¤Ç¼¨¤µ¤ì¤¿Ê¸»úÎ󤫤é¤ÎÆþÎϤòÆɤ߹þ¤à¡£
178 .PP
179 .\"O The
180 .\"O .BR vfscanf ()
181 .\"O function is analogous to
182 .\"O .BR vfprintf (3)
183 .\"O and reads input from the stream pointer
184 .\"O .I stream
185 .\"O using a variable argument list of pointers (see
186 .\"O .BR stdarg (3).
187 .BR vfscanf ()
188 ´Ø¿ô¤Ï
189 .BR vfprintf (3)
190 ¤ÈƱÍͤˡ¢¥¹¥È¥ê¡¼¥à¥Ý¥¤¥ó¥¿
191 .I stream
192 ¤«¤é¤ÎÆþÎϤò¥Ý¥¤¥ó¥¿¤Î²ÄÊÑĹ°ú¤­¿ô¥ê¥¹¥È¤òÍѤ¤¤ÆÆɤ߹þ¤à
193 .RB ( stdarg (3)
194 ¤ò»²¾È)¡£
195 .\"O The
196 .\"O .BR vscanf ()
197 .\"O function scans a variable argument list from the standard input and the
198 .\"O .BR vsscanf ()
199 .\"O function scans it from a string; these are analogous to the
200 .\"O .BR vprintf (3)
201 .\"O and
202 .\"O .BR vsprintf (3)
203 .\"O functions respectively.
204 .BR vscanf ()
205 ´Ø¿ô¤Ï¡¢²ÄÊÑĹ°ú¤­¿ô¤Î¥ê¥¹¥È¤Ë´ð¤Å¤­É¸½àÆþÎϤ«¤é¤ÎÆɤ߼è¤ê¤ò¹Ô¤¦¡£
206 .BR vsscanf ()
207 ´Ø¿ô¤Ï¤½¤Î¥ê¥¹¥È¤Ë´ð¤Å¤­Ê¸»úÎ󤫤éÆɤ߼è¤ë¡£
208 ¤³¤ì¤é¤Î´Ø·¸¤Ï
209 .BR vprintf (3)
210 ¤È
211 .BR vsprintf (3)
212 ´Ø¿ô¤Î´Ø·¸¤ÈƱÍͤǤ¢¤ë¡£
213 .PP
214 .\"O The
215 .\"O .I format
216 .\"O string consists of a sequence of
217 .\"O .I directives
218 .\"O which describe how to process the sequence of input characters.
219 .\"O If processing of a directive fails, no further input is read, and
220 .\"O .BR scanf ()
221 .\"O returns.
222 .\"O A "failure" can be either of the following:
223 .\"O .IR "input failure" ,
224 .\"O meaning that input characters were unavailable, or
225 .\"O .IR "matching failure" ,
226 .\"O meaning that the input was inappropriate (see below).
227 .I format
228 ʸ»úÎó¤Ï
229 .I "¡ÖÌ¿Îá¡× (directive)"
230 ¤ÎÎó¤Ç¹½À®¤µ¤ì¤ë¡£Ì¿Îá¤ÏÆþÎÏʸ»ú¤Î·ÏÎó¤ò¤É¤Î¤è¤¦¤Ë½èÍý¤¹¤ë¤«¤ò»Ø¼¨¤¹¤ë
231 ¤â¤Î¤Ç¤¢¤ë¡£¤¢¤ëÌ¿Îá¤Î½èÍý¤¬¼ºÇÔ¤¹¤ë¤È¡¢ÆþÎϤϤ½¤ì°Ê¾åÆɤ߹þ¤Þ¤ì¤º¡¢
232 .BR scanf ()
233 ¤ÏÊ֤롣¡Ö¼ºÇԡפÏ
234 .I "¡ÖÆþÎϤμºÇÔ¡× (input failure)"
235 ¤È
236 .I "¡Ö°ìÃפμºÇÔ¡× (matching failure)"
237 ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£
238 ÆþÎϤμºÇÔ¤ÏÆþÎÏʸ»ú¤¬»ÈÍѤǤ­¤Ê¤«¤Ã¤¿¤³¤È¤ò°ÕÌ£¤·¡¢
239 °ìÃפμºÇÔ¤ÏÆþÎϤ¬ÉÔŬÀڤǤ¢¤Ã¤¿¤³¤È (²¼µ­»²¾È) ¤ò°ÕÌ£¤¹¤ë¡£
240
241 .\"O A directive is one of the following:
242 Ì¿Îá¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë:
243 .TP
244 \(bu
245 .\"O A sequence of white-space characters (space, tab, newline, etc.; see
246 .\"O .BR isspace (3)).
247 .\"O This directive matches any amount of white space,
248 .\"O including none, in the input.
249 ¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹ (¥¹¥Ú¡¼¥¹¡¢¥¿¥Ö¡¢²þ¹Ô¤Ê¤É;
250 .BR isspace (3)
251 »²¾È) ¤ÎÎó¡£
252 ¤³¤ÎÌ¿Îá¤Ï¡¢ÆþÎÏÃæ¤ÎǤ°Õ¤Î¸Ä¿ô¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤Ë°ìÃפ¹¤ë¡£
253 (¡Ö²¿¤â¤Ê¤·¡×¤Ë¤â°ìÃפ¹¤ë)¡£
254 .TP
255 \(bu
256 .\"O An ordinary character (i.e., one other than white space or \(aq%\(aq).
257 .\"O This character must exactly match the next character of input.
258 Ä̾ïʸ»ú (¤Ä¤Þ¤ê¡¢¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤È \(aq%\(aq °Ê³°¤Îʸ»ú)¡£
259 ¤³¤Îʸ»ú¤ÏÆþÎϤμ¡¤Îʸ»ú¤ËÀµ³Î¤Ë°ìÃפ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
260 .TP
261 \(bu
262 .\"O A conversion specification,
263 .\"O which commences with a \(aq%\(aq (percent) character.
264 .\"O A sequence of characters from the input is converted according to
265 .\"O this specification, and the result is placed in the corresponding
266 .\"O .I pointer
267 .\"O argument.
268 .\"O If the next item of input does not match the conversion specification,
269 .\"O the conversion fails\(emthis is a
270 .\"O .IR "matching failure" .
271 ÊÑ´¹»ØÄê¡£ÊÑ´¹»ØÄê¤Ï \(aq%\(aq (¥Ñ¡¼¥»¥ó¥È) Ê¸»ú¤Ç»Ï¤Þ¤ë¡£
272 ÆþÎϤµ¤ì¤¿Ê¸»ú¤Î·ÏÎó¤Ï¤³¤Î»ØÄê¤Ë¤â¤È¤Å¤¤¤ÆÊÑ´¹¤µ¤ì¡¢
273 ÊÑ´¹·ë²Ì¤ÏÂбþ¤¹¤ë
274 .I pointer
275 °ú¤­¿ô¤¬»Ø¤¹¾ì½ê¤Ë³ÊǼ¤µ¤ì¤ë¡£
276 ÆþÎϤμ¡¤Îʸ»ú¤¬ÊÑ´¹»ØÄê¤È°ìÃפ·¤Ê¤¤¾ì¹ç¤Ï¡¢ÊÑ´¹¤Ï¼ºÇÔ¤¹¤ë
277 \(em¤³¤ì¤¬
278 .I "¡Ö°ìÃפμºÇÔ¡× (matching failure)"
279 ¤Ç¤¢¤ë¡£
280 .PP
281 .\"O Each
282 .\"O .I conversion specification
283 .\"O in
284 .\"O .I format
285 .\"O begins with either the character \(aq%\(aq or the character sequence
286 .\"O "\fB%\fP\fIn\fP\fB$\fP"
287 .\"O (see below for the distinction) followed by:
288 .I format
289 Ãæ¤Î³Æ¡¹¤Î
290 .I "¡ÖÊÑ´¹»ØÄê¡×"
291 ¤Ïʸ»ú \(aq%\(aq ¤«Ê¸»ú·ÏÎó "\fB%\fP\fIn\fP\fB$\fP"
292 (°ã¤¤¤Ë¤Ä¤¤¤Æ¤Ï¸å½Ò) ¤Ç»Ï¤Þ¤ê¡¢°Ê²¼¤ÎÍ×ÁǤ¬Â³¤¯¡£
293 .TP
294 \(bu
295 .\"O An optional \(aq*\(aq assignment-suppression character:
296 .\"O .BR scanf ()
297 .\"O reads input as directed by the conversion specification,
298 .\"O but discards the input.
299 .\"O No corresponding
300 .\"O .I pointer
301 .\"O argument is required, and this specification is not
302 .\"O included in the count of successful assignments returned by
303 .\"O .BR scanf ().
304 ÂåÆþÍÞÀ©Ê¸»ú \(aq*\(aq (¾Êά²Äǽ)¡£
305 .BR scanf ()
306 ¤ÏÊÑ´¹»ØÄê¤Ë»Ø¼¨¤µ¤ì¤¿Ä̤êÆþÎϤòÆɤ߹þ¤à¤¬¡¢¤½¤ÎÆþÎϤϼΤƤé¤ì¤ë¡£
307 Âбþ¤¹¤ë
308 .I pointer
309 °ú¤­¿ô¤ÏɬÍפʤ¯¡¢
310 .BR scanf ()
311 ¤¬ÊÖ¤¹ÂåÆþ¤¬À®¸ù¤·¤¿¿ô¤Ë¤³¤Î»ØÄê¤Ï´Þ¤Þ¤ì¤Ê¤¤¡£
312 .TP
313 \(bu
314 .\"O An optional \(aqa\(aq character.
315 .\"O This is used with string conversions, and relieves the caller of the
316 .\"O need to allocate a corresponding buffer to hold the input: instead,
317 .\"O .BR scanf ()
318 .\"O allocates a buffer of sufficient size,
319 .\"O and assigns the address of this buffer to the corresponding
320 .\"O .I pointer
321 .\"O argument, which should be a pointer to a
322 .\"O .I "char *"
323 .\"O variable (this variable does not need to be initialized before the call).
324 .\"O The caller should subsequently
325 .\"O .BR free (3)
326 .\"O this buffer when it is no longer required.
327 .\"O This is a GNU extension;
328 .\"O C99 employs the \(aqa\(aq character as a conversion specifier (and
329 .\"O it can also be used as such in the GNU implementation).
330 ʸ»ú \(aqa\(aq (¾Êά²Äǽ)¡£¤³¤ì¤Ïʸ»úÎóÊÑ´¹¤È¤È¤â¤Ë»ÈÍѤµ¤ì¡¢¤³¤ì¤ò»È¤¦¤È
331 ¸Æ¤Ó½Ð¤·¸µ¤¬ÆþÎϤòÊÝ»ý¤¹¤ëÂбþ¤¹¤ë¥Ð¥Ã¥Õ¥¡¤ò³ÎÊݤ¹¤ëɬÍפ¬¤Ê¤¯¤Ê¤ë¡£
332 Âå¤ï¤ê¤Ë
333 .BR scanf ()
334 ¤¬É¬ÍפÊÂ礭¤µ¤Î¥Ð¥Ã¥Õ¥¡¤ò³ÎÊݤ·¡¢¤³¤Î¥Ð¥Ã¥Õ¥¡¤Î¥¢¥É¥ì¥¹¤ò
335 Âбþ¤¹¤ë
336 .I pointer
337 °ú¤­¿ô¤ËÂåÆþ¤¹¤ë¡£
338 .I pointer
339 °ú¤­¿ô¤Ï
340 .I "char *"
341 ·¿¤ÎÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
342 (ÊÑ¿ô¼«ÂΤϸƤӽФ·Á°¤Ë½é´ü²½¤µ¤ì¤Æ¤¤¤ëɬÍפϤʤ¤)¡£
343 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢ÉÔÍפˤʤä¿»þÅÀ¤Ç¡¢¤³¤Î¥Ð¥Ã¥Õ¥¡¤ò
344 .BR free (3)
345 ¤¹¤Ù¤­¤Ç¤¢¤ë¡£¤³¤Îµ¡Ç½¤Ï GNU ¤Ë¤è¤ë³ÈÄ¥¤Ç¤¢¤ë¡£
346 C99 ¤Ï \(aqa\(aq Ê¸»ú¤òÊÑ´¹»ØÄê¤È¤·¤Æ»ÈÍѤ·¤Æ¤¤¤ë
347 (¤³¤Á¤é¤â GNU ¤Î¼ÂÁõ¤ÈƱ¤¸¤è¤¦¤Ë»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë)¡£
348 .TP
349 \(bu
350 .\"O An optional decimal integer which specifies the
351 .\"O .IR "maximum field width" .
352 .\"O Reading of characters stops either when this maximum is reached or
353 .\"O when a nonmatching character is found, whichever happens first.
354 .\"O Most conversions discard initial white space characters (the exceptions
355 .\"O are noted below),
356 .\"O and these discarded characters don't count toward the maximum field width.
357 .\"O String input conversions store a terminating null byte (\(aq\\0\(aq)
358 .\"O to mark the end of the input;
359 .\"O the maximum field width does not include this terminator.
360 .I "¡ÖºÇÂç¥Õ¥£¡¼¥ë¥ÉÉý¡×"
361 ¤ò»ØÄꤹ¤ë 10¿Ê¿ô (¾Êά²Äǽ)¡£
362 ¤³¤ÎºÇÂçÃͤË㤹¤ë¤«¡¢°ìÃפ·¤Ê¤¤Ê¸»ú¤¬¸«¤Ä¤«¤ë¤«¡¢¤Î¤É¤Á¤é¤«¤Ë
363 ¤Ê¤ë¤È¡¢Ê¸»ú¤ÎÆɤ߹þ¤ß¤òÄä»ß¤¹¤ë¡£
364 ¤Û¤È¤ó¤É¤ÎÊÑ´¹¤Ç¤Ï¡¢ÀèƬ¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹Ê¸»ú¤Ï¼Î¤Æ¤é¤ì
365 (Îã³°¤Ë¤Ä¤¤¤Æ¤Ï¸å½Ò¤¹¤ë)¡¢
366 ¼Î¤Æ¤é¤ì¤¿¤³¤ì¤é¤Îʸ»ú¤ÏºÇÂç¥Õ¥£¡¼¥ë¥ÉÉý¤Î·×»»¤Ë¤Ï´Þ¤Þ¤ì¤Ê¤¤¡£
367 ʸ»úÎó¤ÎÆþÎÏÊÑ´¹¤Ç¤Ï¡¢ÆþÎϤÎËöÈø¤ò¼¨¤¹½ªÃ¼¤Î NULL ¥Ð¥¤¥È (\(aq\\0\(aq)
368 ¤â³ÊǼ¤µ¤ì¤ë¤¬¡¢ºÇÂç¥Õ¥£¡¼¥ë¥ÉÉý¤Ë¤Ï¤³¤Î½ªÃ¼¥Ð¥¤¥È¤Ï´Þ¤Þ¤ì¤Ê¤¤¡£
369 .TP
370 \(bu
371 .\"O An optional
372 .\"O .IR "type modifier character" .
373 .\"O For example, the
374 .\"O .B l
375 .\"O type modifier is used with integer conversions such as
376 .\"O .B %d
377 .\"O to specify that the corresponding
378 .\"O .I pointer
379 .\"O argument refers to a
380 .\"O .I "long int"
381 .\"O rather than a pointer to an
382 .\"O .IR int .
383 .I "¡Ö·¿½¤¾þ»Ò¡× (type modifier characters)"
384 (¾Êά²Äǽ)¡£
385 Î㤨¤Ð¡¢·¿½¤¾þ»Ò
386 .B l
387 ¤ò
388 .B %d
389 ¤Ê¤É¤ÎÀ°¿ôÊÑ´¹¤È°ì½ï¤Ë»È¤¦¤È¡¢Âбþ¤¹¤ë
390 .I pointer
391 °ú¤­¿ô¤¬
392 .I int
393 ¤Ç¤Ï¤Ê¤¯
394 .I "long int"
395 ¤ò»²¾È¤·¤Æ¤¤¤ë¤³¤È¤ò»ØÄê¤Ç¤­¤ë¡£
396 .TP
397 \(bu
398 .\"O A
399 .\"O .I "conversion specifier"
400 .\"O that specifies the type of input conversion to be performed.
401 .I "¡ÖÊÑ´¹»ØÄê¡×"
402 : ¼Â¹Ô¤¹¤Ù¤­ÆþÎÏÊÑ´¹¤Î¼ïÎà¤ò»ØÄꤹ¤ë¡£
403 .PP
404 .\"O The conversion specifications in
405 .\"O .I format
406 .\"O are of two forms, either beginning with \(aq%\(aq or beginning with
407 .\"O "\fB%\fP\fIn\fP\fB$\fP".
408 .\"O The two forms should not be mixed in the same
409 .\"O .I format
410 .\"O string, except that a string containing
411 .\"O "\fB%\fP\fIn\fP\fB$\fP"
412 .\"O specifications can include
413 .\"O .B %%
414 .\"O and
415 .\"O .BR %* .
416 .I format
417 Ãæ¤ÎÊÑ´¹»ØÄê¤Ï¡¢\(aq%\(aq ¤Ç»Ï¤Þ¤ë¤«¡¢
418 "\fB%\fP\fIn\fP\fB$\fP" ¤Ç»Ï¤Þ¤ë¤«¤Î¡¢¤¤¤º¤ì¤«¤Î·Á¼°¤Ç¤¢¤ë¡£
419 ¤³¤ì¤é 2¤Ä¤Î·Á¼°¤òƱ¤¸
420 .I format
421 ʸ»úÎó¤Ëº®¤¼¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£Ã¢¤·¡¢"\fB%\fP\fIn\fP\fB$\fP" ¤ò
422 ´Þ¤àʸ»úÎó¤Ë
423 .B %%
424 ¤È
425 .B %*
426 ¤ò´Þ¤á¤ë¤³¤È¤Ï¤Ç¤­¤ë¡£
427 .\"O If
428 .\"O .I format
429 .\"O contains \(aq%\(aq
430 .\"O specifications then these correspond in order with successive
431 .\"O .I pointer
432 .\"O arguments.
433 .I format
434 ¤Ë \(aq%\(aq »ØÄ꤬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢³Æ¡¹¤Î \(aq%\(aq »ØÄê¤È
435 ¸å³¤Î
436 .I pointer
437 °ú¤­¿ô¤Ï¤½¤Î½çÈÖÄ̤ê¤ËÂбþ¤¹¤ë¡£
438 .\"O In the
439 .\"O "\fB%\fP\fIn\fP\fB$\fP"
440 .\"O form (which is specified in POSIX.1-2001, but not C99),
441 .\"O .I n
442 .\"O is a decimal integer that specifies that the converted input should
443 .\"O be placed in the location referred to by the
444 .\"O .IR n -th
445 .\"O .I pointer
446 .\"O argument following
447 .\"O .IR format .
448 "\fB%\fP\fIn\fP\fB$\fP" ·Á¼°
449 (POSIX.1-2001 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤ë¤¬¡¢C99 ¤Ë¤Ï¤Ê¤¤)
450 ¤Ç¤Ï¡¢
451 .I n
452 ¤Ï 10¿Ê¿ô¤Ç¤¢¤ê¡¢ÊÑ´¹¸å¤ÎÆþÎϤò
453 .I format
454 ¤Î¸å¤í¤Î
455 .I n
456 ÈÖÌܤÎ
457 .I pointer
458 °ú¤­¿ô¤¬»²¾È¤¹¤ë¾ì½ê¤Ë³ÊǼ¤¹¤ë¤³¤È¤ò»ØÄꤹ¤ë¡£
459 .\"O .SS Conversions
460 .SS ÊÑ´¹
461 .\"O The following
462 .\"O .I "type modifier characters"
463 .\"O can appear in a conversion specification:
464 ÊÑ´¹»ØÄê¤Ë¤Ï¡¢°Ê²¼¤Î
465 .I "¡Ö·¿½¤¾þ»Ò¡×"
466 ¤òÆþ¤ì¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
467 .TP
468 .B h
469 .\"O Indicates that the conversion will be one of
470 .\"O \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, or \fBn\fP
471 .\"O and the next pointer is a pointer to a
472 .\"O .I short int
473 .\"O or
474 .\"O .I unsigned short int
475 .\"O (rather than
476 .\"O .IR int ).
477 ÊÑ´¹¤¬
478 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, \fBn\fP
479 ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ê¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
480 .RI ( int
481 ¤Ç¤Ï¤Ê¤¯)
482 .I short int
483 ¤«
484 .I unsigned short int
485 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
486 .TP
487 .B hh
488 .\"O As for
489 .\"O .BR h ,
490 .\"O but the next pointer is a pointer to a
491 .\"O .I signed char
492 .\"O or
493 .\"O .IR "unsigned char" .
494 .B h
495 ¤ÈƱ¤¸¤À¤¬¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
496 .I signed char
497 ¤«
498 .I unsigned char
499 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
500 .TP
501 .B j
502 .\"O As for
503 .\"O .BR h ,
504 .\"O but the next pointer is a pointer to an
505 .\"O .I intmax_t
506 .\"O or a
507 .\"O .IR uintmax_t .
508 .\"O This modifier was introduced in C99.
509 .B h
510 ¤ÈƱ¤¸¤À¤¬¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
511 .I intmax_t
512 ¤«
513 .I uintmax_t
514 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
515 ¤³¤Î½¤¾þ»Ò¤Ï C99 ¤ÇƳÆþ¤µ¤ì¤¿¡£
516 .TP
517 .B l
518 .\"O Indicates either that the conversion will be one of
519 .\"O \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, or \fBn\fP
520 .\"O and the next pointer is a pointer to a
521 .\"O .I long int
522 .\"O or
523 .\"O .I unsigned long int
524 .\"O (rather than
525 .\"O .IR int ),
526 .\"O or that the conversion will be one of
527 .\"O \fBe\fP, \fBf\fP, or \fBg\fP
528 .\"O and the next pointer is a pointer to
529 .\"O .I double
530 .\"O (rather than
531 .\"O .IR float ).
532 ÊÑ´¹¤¬
533 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, \fBn\fP
534 ¤«
535 .B n
536 ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ê¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
537 .RI ( int
538 ¤Ç¤Ï¤Ê¤¯)
539 .I long int
540 ¤«
541 .I unsigned long int
542 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¡¢¤Þ¤¿¤Ï¡¢ÊÑ´¹¤¬
543 \fBe\fP, \fBf\fP, \fBg\fP
544 ¤Î¤¦¤Á¤Î¤Ò¤È¤Ä¤Ç¤¢¤ê¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
545 .RI ( float
546 ¤Ç¤Ï¤Ê¤¯)
547 .I double
548 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
549 .\"O Specifying two
550 .\"O .B l
551 .\"O characters is equivalent to
552 .\"O .BR L .
553 .\"O If used with
554 .\"O .B %c
555 .\"O or
556 .\"O .B %s
557 .\"O the corresponding parameter is considered
558 .\"O as a pointer to a wide character or wide-character string respectively.
559 .\"O .\" This use of l was introduced in Amendment 1 to ISO C90.
560 .B l
561 ʸ»ú¤òÆó¤Ä»ØÄꤹ¤ë¤È¡¢
562 .B L
563 ¤ÈƱ¤¸°ÕÌ£¤È¤Ê¤ë¡£
564 .B %c
565 ¤ä
566 .B %s
567 ¤È¤È¤â¤Ë»ÈÍѤ¹¤ë¤È¡¢
568 ¥Ñ¥é¥á¡¼¥¿¤Ï¤½¤ì¤¾¤ì¥ï¥¤¥Éʸ»ú¤ä¥ï¥¤¥Éʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤È
569 ¤ß¤Ê¤µ¤ì¤ë¡£
570 .\" l ¤Î¤³¤Î»ÈÍÑË¡¤Ï ISO C90 ¤Î Amendment 1 ¤ÇƳÆþ¤µ¤ì¤¿¡£
571 .TP
572 .B L
573 .\"O Indicates that the conversion will be either
574 .\"O \fBe\fP, \fBf\fP, or \fBg\fP
575 .\"O and the next pointer is a pointer to
576 .\"O .I "long double"
577 .\"O or the conversion will be
578 .\"O \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, or \fBx\fP
579 .\"O and the next pointer is a pointer to
580 .\"O .IR "long long" .
581 \fBe\fP, \fBf\fP, \fBg\fP
582 ÊÑ´¹¤Ç¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
583 .I "long double"
584 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£¤â¤·¤¯¤Ï¡¢
585 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP
586 ÊÑ´¹¤Ç¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
587 .I "long long"
588 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
589 .\"O .\" MTK, Jul 05: The following is no longer true for modern
590 .\"O .\" ANSI C (i.e., C99):
591 .\"O .\" (Note that long long is not an
592 .\"O .\" ANSI C
593 .\"O .\" type. Any program using this will not be portable to all
594 .\"O .\" architectures).
595 .\" MTK, Jul 05: °Ê²¼¤ÎÆâÍƤϿ·¤·¤¤ ANSI C (¤Ä¤Þ¤ê C99) ¤Ç¤Ï
596 .\" ¤â¤Ï¤äÀµ¤·¤¯¤Ê¤¤¡£
597 .\" (long long ¤Ï
598 .\" .I ANSI C
599 .\" ¤Çµ¬Äꤵ¤ì¤¿·¿¤Ç¤Ï¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤è¤¦¡£
600 .\" ¤³¤ì¤òÍѤ¤¤¿¥×¥í¥°¥é¥à¤ÏÁ´¤Æ¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤ËÂФ·¤Æ
601 .\" °Ü¿¢²Äǽ¤Ç¤Ï¤Ê¤¤¡£)
602 .TP
603 .B q
604 .\"O equivalent to
605 .\"O .BR L .
606 .\"O This specifier does not exist in ANSI C.
607 .B L
608 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
609 ¤³¤Î½¤¾þ»Ò¤Ï ANSI C ¤Ë¤Ï¸ºß¤·¤Ê¤¤¡£
610 .TP
611 .B t
612 .\"O As for
613 .\"O .BR h ,
614 .\"O but the next pointer is a pointer to a
615 .\"O .IR ptrdiff_t .
616 .\"O This modifier was introduced in C99.
617 .B h
618 ¤ÈƱÍͤÀ¤¬¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
619 .I ptrdiff_t
620 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
621 ¤³¤Î½¤¾þ»Ò¤Ï C99 ¤ÇƳÆþ¤µ¤ì¤¿¡£
622 .TP
623 .B z
624 .\"O As for
625 .\"O .BR h ,
626 .\"O but the next pointer is a pointer to a
627 .\"O .IR size_t .
628 .\"O This modifier was introduced in C99.
629 .B h
630 ¤ÈƱÍͤÀ¤¬¡¢¼¡¤Î¥Ý¥¤¥ó¥¿¤¬
631 .I size_t
632 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
633 ¤³¤Î½¤¾þ»Ò¤Ï C99 ¤ÇƳÆþ¤µ¤ì¤¿¡£
634 .PP
635 .\"O The following
636 .\"O .I "conversion specifiers"
637 .\"O are available:
638 °Ê²¼¤Î
639 .I ¡ÖÊÑ´¹»ØÄê»Ò¡×
640 ¤¬ÍøÍѲÄǽ¤Ç¤¢¤ë¡£
641 .TP
642 .B %
643 .\"O Matches a literal \(aq%\(aq.
644 .\"O That is,
645 .\"O .B %\&%
646 .\"O in the format string matches a
647 .\"O single input \(aq%\(aq character.
648 .\"O No conversion is done (but initial white space characters are discarded),
649 .\"O and assignment does not occur.
650 ʸ»ú \(aq%\(aq ¤ËÂбþ¤¹¤ë¡£
651 ½ñ¼°Ê¸»úÎó¤ÎÃæ¤Î
652 .B %\&%
653 ¤Ïñ°ì¤Îʸ»ú \(aq%\(aq ¤ËÂбþ¤¹¤ë¡£
654 ÊÑ´¹¤Ï¹Ô¤ï¤ì¤º (⤷¡¢ÀèƬ¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹Ê¸»ú¤Ï¼Î¤Æ¤é¤ì¤ë)¡¢
655 ÊÑ¿ô¤Ø¤ÎÂåÆþ¤ÏÀ¸¤¸¤Ê¤¤¡£
656 .TP
657 .B d
658 .\"O Matches an optionally signed decimal integer;
659 .\"O the next pointer must be a pointer to
660 .\"O .IR int .
661 Éä¹æ¤Ä¤­¤Î 10¿Ê¤ÎÀ°¿ô¤ËÂбþ¤¹¤ë¡£
662 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
663 .I int
664 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
665 .TP
666 .B D
667 .\"O Equivalent to
668 .\"O .IR ld ;
669 .\"O this exists only for backward compatibility.
670 .\"O (Note: thus only in libc4.
671 .\"O In libc5 and glibc the
672 .\"O .B %D
673 .\"O is silently ignored, causing old programs to fail mysteriously.)
674 .I ld
675 ¤ÈƱ°ì¤Ç¤¢¤ë¡£¤³¤ì¤Ï°ÊÁ°¤Î»ÅÍͤȤθߴ¹À­¤À¤±¤Î¤¿¤á¤Ë¤¢¤ë¡£
676 (Ãí°Õ: ¤³¤ì¤Ï libc4 ¤Î¾ì¹ç¤À¤±¤Ç¤¢¤ë¡£ libc5 ¤ä glibc ¤Ç¤Ï
677 .B %D
678 ¤Ï°ÅÌۤΤ¦¤Á¤Ë̵»ë¤µ¤ì¡¢¸Å¤¤¥×¥í¥°¥é¥à¤Ë¤ª¤¤¤ÆÆæ¤ËËþ¤Á¤¿¼ºÇԤθ¶°ø¤È¤Ê¤ë¡£)
679 .TP
680 .B i
681 .\"O Matches an optionally signed integer; the next pointer must be a pointer to
682 .\"O .IR int .
683 .\"O The integer is read in base 16 if it begins with
684 .\"O .I 0x
685 .\"O or
686 .\"O .IR 0X ,
687 .\"O in base 8 if it begins with
688 .\"O .IR 0 ,
689 .\"O and in base 10 otherwise.
690 .\"O Only characters that correspond to the base are used.
691 Éä¹æ¤Ä¤­À°¿ô¤ËÂбþ¤¹¤ë¡£
692 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
693 .I int
694 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
695 ¤³¤ÎÀ°¿ô¤Ï
696 .I 0x
697 ¤Þ¤¿¤Ï
698 .I 0X
699 ¤Ç³«»Ï¤¹¤ë¾ì¹ç¤Ë¤Ï 16 ¿Ê¿ô¡¢
700 .I 0
701 ¤Ç³«»Ï¤¹¤ë¾ì¹ç¤Ë¤Ï 8 ¿Ê¿ô¡¢¤½¤Î¾¤Î¾ì¹ç¤Ë¤Ï 10¿Ê¿ô¤È¤·¤ÆÆɤ߹þ¤Þ¤ì¤ë¡£
702 ¤³¤ÎÊÑ´¹¤Ç»ÈÍѤµ¤ì¤ëʸ»ú¤Ï¡¢¤³¤ì¤é¤Î´ð¿ô¤ËÂбþ¤·¤Æ¤¤¤ë¤â¤Î¤À¤±¤Ç¤¢¤ë¡£
703 .TP
704 .B o
705 .\"O Matches an unsigned octal integer; the next pointer must be a pointer to
706 .\"O .IR "unsigned int" .
707 Éä¹æ¤Ê¤·¤Î 8 ¿Ê¤ÎÀ°¿ô¤ËÂбþ¤¹¤ë¡£
708 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
709 .I "unsigned int"
710 ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
711 .TP
712 .B u
713 .\"O Matches an unsigned decimal integer; the next pointer must be a
714 .\"O pointer to
715 .\"O .IR "unsigned int" .
716 Éä¹æ¤Ê¤·¤Î 10¿Ê¤ÎÀ°¿ô¤ËÂбþ¤¹¤ë¡£
717 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
718 .I "unsigned int"
719 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
720 .TP
721 .B x
722 .\"O Matches an unsigned hexadecimal integer; the next pointer must
723 .\"O be a pointer to
724 .\"O .IR "unsigned int" .
725 Éä¹æ¤Ê¤·¤Î 16 ¿Ê¤ÎÀ°¿ô¤ËÂбþ¤¹¤ë¡£
726 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
727 .I "unsigned int"
728 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
729 .TP
730 .B X
731 .\"O Equivalent to
732 .\"O .BR x .
733 .B x
734 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
735 .TP
736 .B f
737 .\"O Matches an optionally signed floating-point number; the next pointer must
738 .\"O be a pointer to
739 .\"O .IR float .
740 Éä¹æ¤Ä¤­ÉâÆ°¾®¿ôÅÀ¼Â¿ô¤ËÂбþ¤¹¤ë¡£
741 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
742 .I float
743 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
744 .TP
745 .B e
746 .\"O Equivalent to
747 .\"O .BR f .
748 .B f
749 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
750 .TP
751 .B g
752 .\"O Equivalent to
753 .\"O .BR f .
754 .B f
755 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
756 .TP
757 .B E
758 .\"O Equivalent to
759 .\"O .BR f .
760 .B f
761 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
762 .TP
763 .B a
764 .\"O (C99) Equivalent to
765 .\"O .BR f .
766 (C99)
767 .B f
768 ¤ÈƱ°ì¤Ç¤¢¤ë¡£
769 .TP
770 .B s
771 .\"O Matches a sequence of non-white-space characters;
772 .\"O the next pointer must be a pointer to character array that is
773 .\"O long enough to hold the input sequence and
774 .\"O the terminating null byte (\(aq\\0\(aq), which is added automatically.
775 .\"O The input string stops at white space or at the maximum field
776 .\"O width, whichever occurs first.
777 ¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤Ç¤Ï¤Ê¤¤Ê¸»ú¤Ç¹½À®¤µ¤ì¤¿Ê¸»úÎó¤ËÂбþ¤¹¤ë¡£
778 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ïʸ»ú¤ÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
779 ¤½¤Îʸ»úÇÛÎó¤Ï¡¢ÆþÎϤµ¤ì¤¿Ê¸»úÎó¤È (¼«Æ°Åª¤ËÄɲ䵤ì¤ë) ½ªÃ¼¤Î NULL
780 ¥Ð¥¤¥È (\(aq\\0\(aq) ¤ò³ÊǼ¤¹¤ë¤Î¤Ë½½Ê¬¤ÊÂ礭¤µ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
781 ʸ»úÎó¤ÎÆþÎϤϡ¢¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤¬ÆþÎϤµ¤ì¤ë¤«¡¢ºÇÂç¥Õ¥£¡¼¥ë¥ÉÉý¤Ë
782 㤹¤ë¤«¡¢¤Î¤É¤Á¤é¤«¤¬µ¯¤³¤ë¤ÈÄä»ß¤µ¤ì¤ë¡£
783 .TP
784 .B c
785 .\"O Matches a sequence of characters whose length is specified by the
786 .\"O .I maximum field width
787 .\"O (default 1); the next pointer must be a pointer to
788 .\"O .IR char ,
789 .\"O and there must be enough room for all the characters (no terminating
790 .\"O null byte
791 .\"O is added).
792 .\"O The usual skip of leading white space is suppressed.
793 .\"O To skip white space first, use an explicit space in the format.
794 .I "¡ÖºÇÂç¥Õ¥£¡¼¥ë¥ÉÉý¡×"
795 (¥Ç¥Õ¥©¥ë¥È¤Ï 1) ¤Ç»ØÄꤵ¤ì¤¿Éý¤Îʸ»ú¤ÎÎó¤ËÂбþ¤¹¤ë¡£
796 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
797 .I char
798 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¡¢¤¹¤Ù¤Æ¤Îʸ»ú¤ò³ÊǼ¤¹¤ë¤Î¤Ë½½Ê¬¤ÊÎΰ褬
799 ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ (½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤ÏÄɲ䵤ì¤Ê¤¤)¡£
800 Ä̾ï¹Ô¤ï¤ì¤ëÀèƬ¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤ÎÆɤßÈô¤Ð¤·¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
801 ÀèƬ¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤òÆɤßÈô¤Ð¤¹¤¿¤á¤Ë¤Ï¡¢
802 ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ¤ÎÃæ¤ÇÌÀ¼¨Åª¤Ë¥¹¥Ú¡¼¥¹¤ò»ÈÍѤ¹¤ì¤ÐÎɤ¤¡£
803 .TP
804 .B \&[
805 .\"O Matches a nonempty sequence of characters from the specified set of
806 .\"O accepted characters; the next pointer must be a pointer to
807 .\"O .IR char ,
808 .\"O and there must be enough room for all the characters in the string, plus a
809 .\"O terminating null byte.
810 .\"O The usual skip of leading white space is suppressed.
811 ³ÊǼ¤µ¤ì¤¿Ê¸»úÎó¤Î¤¦¤Á¤«¤é¼è¤ê½Ð¤µ¤ì¤¿¡¢
812 »ØÄꤵ¤ì¤¿Ê¸»ú¤Î½¸¹ç¤Ç¹½À®¤µ¤ì¤ë¶õ¤Ç¤Ï¤Ê¤¤Ê¸»ú¤ÎÎó¤ËÂбþ¤¹¤ë¡£
813 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
814 .I char
815 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
816 ¤½¤³¤Ë¤Ïʸ»úÎóÃæ¤Î¤¹¤Ù¤Æ¤Îʸ»ú¤È½ªÃ¼¤Î NULL ¥Ð¥¤¥È
817 ¤ò³ÊǼ¤¹¤ë¤¿¤á¤Î½½Ê¬¤ÊÎΰ褬¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
818 Ä̾ï¹Ô¤ï¤ì¤ëÀèƬ¤Î¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤ÎÆɤßÈô¤Ð¤·¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
819 .\"O The string is to be made up of characters in (or not in) a particular set;
820 .\"O the set is defined by the characters between the open bracket
821 .\"O .B [
822 .\"O character and a close bracket
823 .\"O .B ]
824 .\"O character.
825 .\"O The set
826 .\"O .I excludes
827 .\"O those characters if the first character after the open bracket is a
828 .\"O circumflex
829 .\"O .RB ( ^ ).
830 ¤³¤Îʸ»úÎó¤ÏÆÃÊ̤ʽ¸¹ç¤ÎÃæ¤Îʸ»ú¤Ç¹½À®¤µ¤ì¤Æ¤¤¤ë¡£
831 ¤³¤Î½¸¹ç¤Ï
832 ³«¤­³ç¸Ì
833 .B [
834 ¤ÈÊĤ¸³ç¸Ì
835 .B ]
836 ¤Î´Ö¤Îʸ»ú¤ÇÄêµÁ¤µ¤ì¤ë¡£
837 ³«¤­³ç¸Ì¤Î¤¢¤È¤ÎºÇ½é¤Îʸ»ú¤¬¶Ê¥¢¥¯¥»¥ó¥Èµ­¹æ
838 .RB ( ^ )
839 ¤Î¾ì¹ç¡¢½¸¹ç¤Ï¤³¤ì¤é¤Îʸ»ú¤ò´Þ¤Þ¤Ê¤¤¤â¤Î¤È¤Ê¤ë¡£
840 .\"O To include a close bracket in the set, make it the first character after
841 .\"O the open bracket or the circumflex; any other position will end the set.
842 .\"O The hyphen character
843 .\"O .B \-
844 .\"O is also special; when placed between two other characters, it adds all
845 .\"O intervening characters to the set.
846 .\"O To include a hyphen, make it the last
847 .\"O character before the final close bracket.
848 ÊĤ¸³ç¸Ì¤ò½¸¹ç¤Ë´Þ¤Þ¤»¤ë¤¿¤á¤Ë¤Ï¡¢¤³¤Îʸ»ú¤ò³«¤­³ç¸Ì¤Þ¤¿¤Ï
849 ¶Ê¥¢¥¯¥»¥ó¥Èµ­¹æ¤Î¤¢¤È¤ÎºÇ½é¤Îʸ»ú¤Ë¤¹¤ì¤Ð¤è¤¤¡£
850 ¤Ä¤Þ¤ê¡¢Â¾¤Î°ÌÃÖ¤ËÊĤ¸³ç¸Ì¤òÃÖ¤¯¤Èʸ»ú¤Î½¸¹ç¤¬½ª¤ë¡£
851 ¥Ï¥¤¥Õ¥ó
852 .B \-
853 ¤â¤Þ¤¿Æüìʸ»ú¤Ç¤¢¤ë¡£
854 Æó¤Ä¤Î°Û¤Ê¤ëʸ»ú¤Î´Ö¤ËÃÖ¤«¤ì¤¿»þ¡¢¤³¤Îʸ»ú¤Ï¡¢
855 ¤½¤Î´Ö¤Ë¤¢¤ëÁ´¤Æ¤Îʸ»ú¤ò½¸¹ç¤Ë²Ã¤¨¤ë¡£
856 ¥Ï¥¤¥Õ¥ó¼«ÂΤò´Þ¤Þ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
857 ³ç¸Ì¤¬ÊĤ¸¤ëÁ°¤ÎºÇ¸å¤Î°ìʸ»ú¤ò¥Ï¥¤¥Õ¥ó¤Ë¤¹¤ì¤Ð¤è¤¤¡£
858 .\"O For instance,
859 .\"O .B [^]0\-9\-]
860 .\"O means
861 .\"O the set "everything except close bracket, zero through nine, and hyphen".
862 .\"O The string ends with the appearance of a character not in the (or, with a
863 .\"O circumflex, in) set or when the field width runs out.
864 Î㤨¤Ð¡¢
865 .B [^]0\-9\-]
866 ¤Ï¡ÖÊĤ¸³ç¸Ì¡¢0 ¡Á 9¡¢¥Ï¥¤¥Õ¥ó¤Î 3 ¼ïÎà¤ò½ü¤¯Á´¤Æ¤Îʸ»ú¡×¤Î½¸¹ç¤ò°ÕÌ£¤¹¤ë¡£
867 ¤³¤Îʸ»úÎó¤Ï
868 ½¸¹ç¤Ë´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤ (¶Ê¥¢¥¯¥»¥ó¥È¤Î¾ì¹ç¤Ë¤Ï´Þ¤Þ¤ì¤ë) Ê¸»ú¤Î
869 ½Ð¸½¤Þ¤¿¤Ï³ÎÊݤµ¤ì¤¿Îΰ褬»È¤¤ÀÚ¤é¤ì¤¿»þ¤Ë½ªÎ»¤¹¤ë¡£
870 .TP
871 .B p
872 .\"O Matches a pointer value (as printed by
873 .\"O .B %p
874 .\"O in
875 .\"O .BR printf (3);
876 .\"O the next pointer must be a pointer to a pointer to
877 .\"O .IR void .
878 .RB ( printf (3)
879 ¤Î
880 .B %p
881 ¤Ç°õ»ú¤µ¤ì¤ë¤è¤¦¤Ê) ¥Ý¥¤¥ó¥¿ÃͤËÂбþ¤¹¤ë¡£
882 ¼¡¤Î¥Ý¥¤¥ó¥¿¤Ï
883 .I void
884 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
885 .TP
886 .B n
887 .\"O Nothing is expected; instead, the number of characters consumed thus far
888 .\"O from the input is stored through the next pointer, which must be a pointer
889 .\"O to
890 .\"O .IR int .
891 ¤É¤ó¤ÊÆþÎϤâɬÍפȤ·¤Ê¤¤¡£
892 ¤½¤Î¤«¤ï¤ê¤Ë¡¢
893 ÆþÎϤ«¤é¤³¤³¤Þ¤Ç¾ÃÈñ¤µ¤ì¤¿Ê¸»ú¿ô¤¬¼¡¤Î¥Ý¥¤¥ó¥¿¤Ç»ØÄꤵ¤ì¤¿¾ì½ê¤Ë
894 ³ÊǼ¤µ¤ì¤ë¡£
895 ¤³¤Î¥Ý¥¤¥ó¥¿¤Ï
896 .I int
897 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
898 .\"O This is
899 .\"O .I not
900 .\"O a conversion, although it can be suppressed with the
901 .\"O .B *
902 .\"O assignment-suppression character.
903 ÊÑ´¹¤òÍÞÀ©¤¹¤ë¤Î¤Ç¤¢¤ì¤Ð
904 .B *
905 ÂåÆþÍÞÀ©Ê¸»ú¤ò»È¤Ã¤ÆÍÞÀ©¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤À¤¬¡¢
906 ¤³¤ÎÊÑ´¹»ØÄê»Ò¤ÏÊÑ´¹¤Ç¤Ï¡Ö¤Ê¤¤¡×¡£
907 .\"O The C standard says: "Execution of a
908 .\"O .B %n
909 .\"O directive does not increment
910 .\"O the assignment count returned at the completion of execution"
911 .\"O but the Corrigendum seems to contradict this.
912 .\"O Probably it is wise
913 .\"O not to make any assumptions on the effect of
914 .\"O .B %n
915 .\"O conversions on the return value.
916 C ¸À¸ì¤Îɸ½àµ¬³Ê¤Ç¤Ï¡Ö¼Â¹Ô¤Î´°Î»»þ¤ËÊÖ¤µ¤ì¤ëÂåÆþ¤Î²ó¿ô¤Ï
917 .B %n
918 Ì¿Îá¤Î¼Â¹Ô¤Ç¤ÏÁý²Ã¤·¤Ê¤¤¡×¤È¤Ê¤Ã¤Æ¤¤¤ë¤¬¡¢
919 Àµ¸íɽ¤ÎÆâÍƤϤ³¤ì¤ÈÌ·½â¤¹¤ë¤è¤¦¤Ç¤¢¤ë¡£¤ª¤½¤é¤¯¡¢
920 .B %n
921 ÊÑ´¹¤¬ÊÖ¤êÃͤËÍ¿¤¨¤ë±Æ¶Á¤Ë¤Ä¤¤¤Æ¤Ï¤É¤Î¤è¤¦¤Ê²¾Äê¤â¤·¤Ê¤¤¤Î¤¬
922 ¸­ÌÀ¤Ç¤¢¤í¤¦¡£
923 .\"O .SH "RETURN VALUE"
924 .SH ÊÖ¤êÃÍ
925 .\"O These functions return the number of input items
926 .\"O successfully matched and assigned,
927 .\"O which can be fewer than provided for,
928 .\"O or even zero in the event of an early matching failure.
929 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢°ìÃפÈÂåÆþ¤¬À®¸ù¤·¤¿ÆþÎÏÍ×ÁǤθĿô¤òÊÖ¤¹¡£
930 ÊÖ¤µ¤ì¤ëÃͤÏÅϤµ¤ì¤¿ÊÑ´¹¤Î¸Ä¿ô¤è¤ê¤â¾¯¤Ê¤¤¤³¤È¤â¤¢¤ê¡¢
931 ºÇ½é¤Ë°ìÃפμºÇÔ¤¬¤¢¤Ã¤¿¾ì¹ç¤Ë¤Ï 0 ¤Ë¤Ê¤ë¤³¤È¤â¤¢¤ë¡£
932
933 .\"O The value
934 .\"O .B EOF
935 .\"O is returned if the end of input is reached before either the first
936 .\"O successful conversion or a matching failure occurs.
937 .\"O .B EOF
938 .\"O is also returned if a read error occurs,
939 .\"O in which case the error indicator for the stream (see
940 .\"O .BR ferror (3))
941 .\"O is set, and
942 .\"O .I errno
943 .\"O is set indicate the error.
944 ºÇ½é¤ÎÊÑ´¹¤¬À®¸ù¤¹¤ëÁ°¤ËÆþÎϤκǸå¤Ë㤷¤Æ¡¢°ìÃפμºÇÔ¤¬µ¯¤³¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
945 .B EOF
946 ¤¬ÊÖ¤µ¤ì¤ë¡£¤Þ¤¿¡¢
947 Æɤ߹þ¤ß¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤â
948 .B EOF
949 ¤¬ÊÖ¤µ¤ì¤ë¡£Æɤ߹þ¤ß¥¨¥é¡¼¤Î¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¥¹¥È¥ê¡¼¥à¤Î
950 ¥¨¥é¡¼»Ø¼¨»Ò¤¬¥»¥Ã¥È¤µ¤ì
951 .RB ( ferror (3)
952 »²¾È)¡¢
953 .I errno
954 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹Ãͤ¬¥»¥Ã¥È¤µ¤ì¤ë¡£
955 .\"O .SH ERRORS
956 .SH ¥¨¥é¡¼
957 .TP
958 .B EAGAIN
959 .\"O The file descriptor underlying
960 .\"O .I stream
961 .\"O is marked nonblocking, and the read operation would block.
962 .I stream
963 ¤ËÂбþ¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ nonblocking ¤È¤Ê¤Ã¤Æ¤ª¤ê¡¢
964 Æɤ߹þ¤ßÁàºî¤ÏÄä»ß (block) ¤¹¤ë¤³¤È¤Ë¤Ê¤ë¡£
965 .TP
966 .B EBADF
967 .\"O The file descriptor underlying
968 .\"O .I stream
969 .\"O is invalid, or not open for reading.
970 .I stream
971 ¤ËÂбþ¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Ìµ¸ú¤Ç¤¢¤ë¤¬¡¢
972 Æɤ߹þ¤ßÍѤ˥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
973 .TP
974 .B EILSEQ
975 .\"O Input byte sequence does not form a valid character.
976 ÆþÎϤµ¤ì¤¿¥Ð¥¤¥ÈÎó¤¬Í­¸ú¤Êʸ»ú¤ò¹½À®¤·¤Æ¤¤¤Ê¤¤¡£
977 .TP
978 .B EINTR
979 .\"O The read operation was interrupted by a signal; see
980 .\"O .BR signal (7).
981 Æɤ߹þ¤ßÁàºî¤¬¥·¥°¥Ê¥ë¤Ë¤è¤ê³ä¤ê¹þ¤Þ¤ì¤¿¡£
982 .BR signal (7)
983 »²¾È¡£
984 .TP
985 .B EINVAL
986 .\"O Not enough arguments; or
987 .\"O .I format
988 .\"O is NULL.
989 °ú¤­¿ô¤¬½½Ê¬¤Ç¤Ê¤¤¡£¤Þ¤¿¤Ï
990 .I format
991 ¤¬ NULL ¤Ç¤¢¤ë¡£
992 .TP
993 .B ENOMEM
994 .\"O Out of memory.
995 ¥á¥â¥êÉÔ­¡£
996 .TP
997 .B ERANGE
998 .\"O The result of an integer conversion would exceed the size
999 .\"O that can be stored in the corresponding integer type.
1000 À°¿ôÊÑ´¹¤Î·ë²Ì¤¬¡¢Âбþ¤¹¤ëÀ°¿ô·¿¤Ë³ÊǼ¤Ç¤­¤ë¥µ¥¤¥º¤ò±Û¤¨¤Æ¤·¤Þ¤¦¡£
1001 .\"O .SH "CONFORMING TO"
1002 .SH ½àµò
1003 .\"O The functions
1004 .\"O .BR fscanf (),
1005 .\"O .BR scanf (),
1006 .\"O and
1007 .\"O .BR sscanf ()
1008 .\"O conform to C89 and C99 and POSIX.1-2001.
1009 .\"O These standards do not specify the
1010 .\"O .B ERANGE
1011 .\"O error.
1012 .BR fscanf (),
1013 .BR scanf (),
1014 .BR sscanf ()
1015 ´Ø¿ô¤Ï C89, C99, POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
1016 ¤³¤ì¤é¤Îɸ½à¤Ç¤Ï¡¢¥¨¥é¡¼
1017 .B ERANGE
1018 ¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1019 .PP
1020 .\"O The
1021 .\"O .B q
1022 .\"O specifier is the 4.4BSD notation for
1023 .\"O .IR "long long" ,
1024 .B q
1025 »ØÄê»Ò¤Ï
1026 .I "long long"
1027 ¤Î 4.4BSD ¤Ç¤Îµ­½ÒÊýË¡¤Ç¤¢¤ë¡£
1028 .\"O while
1029 .\"O .B ll
1030 .\"O or the usage of
1031 .\"O .B L
1032 .\"O in integer conversions is the GNU notation.
1033 °ìÊý¡¢À°¿ôÊÑ´¹¤Ç¤Î
1034 .B ll
1035 ¤Þ¤¿¤Ï
1036 .B L
1037 ¤Î»ÈÍѤϠGNU ¤Ç¤Î³ÈÄ¥¤Ç¤¢¤ë¡£
1038 .PP
1039 .\"O The Linux version of these functions is based on the
1040 .\"O .I GNU
1041 .\"O .I libio
1042 .\"O library.
1043 .\"O Take a look at the
1044 .\"O .I info
1045 .\"O documentation of
1046 .\"O .I GNU
1047 .\"O .I libc (glibc-1.08)
1048 .\"O for a more concise description.
1049 ¤³¤ì¤é¤Î´Ø¿ô¤Î Linux ÈǤÏ
1050 .I GNU
1051 .I libio
1052 ¥é¥¤¥Ö¥é¥ê¡¼¤ò¸µ¤Ë¤·¤Æ¤¤¤ë¡£
1053 ¤è¤ê´Ê·é¤ÊÀâÌÀ¤Ë¤Ï
1054 .I GNU
1055 .I libc (glibc-1.08)
1056 ¤Î
1057 .I info
1058 ʸ½ñ¤ËÌܤòÄ̤¹¤³¤È¡£
1059 .\"O .SH NOTES
1060 .SH Ãí°Õ
1061 .\"O The GNU C library supports a nonstandard extension that causes
1062 .\"O the library to dynamically allocate a string of sufficient size
1063 .\"O for input strings for the
1064 .\"O .B %s
1065 .\"O and
1066 .\"O \fB%a[\fP\fIrange\fP\fB]\fP
1067 .\"O conversion specifiers.
1068 GNU C ¥é¥¤¥Ö¥é¥ê (glibc) ¤Ç¤ÏÈóɸ½à¤Î¥ª¥×¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤ª¤ê¡¢
1069 ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»È¤¦¤ÈÊÑ´¹»ØÄê»Ò
1070 .B %s
1071 ¤ä
1072 \fB%a[\fP\fIrange\fP\fB]\fP
1073 ¤Ø¤ÎÆþÎÏʸ»úÎó¤ËÂФ·¤Æ½½Ê¬¤ÊÂ礭¤µ¤Îʸ»úÎó¤ò¥é¥¤¥Ö¥é¥ê¤¬Æ°Åª¤Ë³ÎÊݤ¹¤ë
1074 ¤è¤¦¤Ë¤Ê¤ë¡£
1075 .\"O .\" This feature seems to be present at least as far back as glibc 2.0.
1076 .\" ¤³¤Îµ¡Ç½¤Ï¾¯¤Ê¤¯¤È¤â glibc 2.0 »þÅÀ¤«¤é¸ºß¤·¤Æ¤¤¤ë¤è¤¦¤À¡£
1077 .\"O To make use of this feature, specify
1078 .\"O .B a
1079 .\"O as a length modifier (thus
1080 .\"O .B %as
1081 .\"O or
1082 .\"O \fB%a[\fP\fIrange\fP\fB]\fP).
1083 .\"O The caller must
1084 .\"O .BR free (3)
1085 .\"O the returned string, as in the following example:
1086 ¤³¤Îµ¡Ç½¤ò»ÈÍѤ¹¤ë¤Ë¤Ï¡¢Ä¹¤µ½¤¾þ»Ò¤È¤·¤Æ
1087 .B a
1088 ¤ò»ØÄꤹ¤ë (¤·¤¿¤¬¤Ã¤Æ¡¢Á´ÂΤȤ·¤Æ¤Ï
1089 .B %as
1090 ¤ä
1091 \fB%a[\fP\fIrange\fP\fB]\fP ¤È¤Ê¤ë)¡£
1092 °Ê²¼¤ÎÎã¤Ë¤¢¤ë¤è¤¦¤Ë¡¢¸Æ¤Ó½Ð¤·Â¦¤ÏÊÖ¤µ¤ì¤¿Ê¸»úÎó¤ò
1093 .BR free (3)
1094 ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1095 .in +4n
1096 .nf
1097
1098 char *p;
1099 int n;
1100
1101 errno = 0;
1102 n = scanf("%a[a-z]", &p);
1103 if (n == 1) {
1104     printf("read: %s\\n", p);
1105     free(p);
1106 } else if (errno != 0) {
1107     perror("scanf");
1108 } else {
1109     fprintf(stderr, "No matching characters\\n"):
1110 }
1111 .fi
1112 .in
1113 .PP
1114 .\"O As shown in the above example, it is only necessary to call
1115 .\"O .BR free (3)
1116 .\"O if the
1117 .\"O .BR scanf ()
1118 .\"O call successfully read a string.
1119 ¾åµ­¤ÎÎã¤Ë¤¢¤ë¤è¤¦¤Ë¡¢
1120 .BR scanf ()
1121 ¤¬Ê¸»úÎó¤ÎÆɤ߹þ¤ß¤ËÀ®¸ù¤·¤¿¾ì¹ç¤Ë¤À¤±¡¢
1122 .BR free (3)
1123 ¤ò¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ë¡£
1124 .PP
1125 .\"O The
1126 .\"O .B a
1127 .\"O modifier is not available if the program is compiled with
1128 .\"O .I "gcc -std=c99"
1129 .\"O or
1130 .\"O .IR "gcc -D_ISOC99_SOURCE"
1131 .\"O (unless
1132 .\"O .B _GNU_SOURCE
1133 .\"O is also specified), in which case the
1134 .\"O .B a
1135 .\"O is interpreted as a specifier for floating-point numbers (see above).
1136 .I "gcc -std=c99"
1137 ¤ä
1138 .I "gcc -D_ISOC99_SOURCE"
1139 ¤Ç¥³¥ó¥Ñ¥¤¥ë¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï
1140 .RB ( _GNU_SOURCE
1141 ¤âƱ»þ¤Ë»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç)¡¢
1142 .B a
1143 ½¤¾þ»Ò¤ÏÍøÍѤǤ­¤Ê¤¤¡£
1144 ¾åµ­¤Î¾ì¹ç¡¢
1145 .B a
1146 ¤Ï (¾å½Ò¤ÎÄ̤ê) ÉâÆ°¾®¿ôÅÀ¿ô¤ò¼¨¤¹ÊÑ´¹»ØÄê»Ò¤È²ò¼á¤µ¤ì¤ë¡£
1147
1148 .\"O Since version 2.7, glibc also provides the
1149 .\"O .B m
1150 .\"O modifier for the same purpose as the
1151 .\"O .BR a
1152 .\"O modifier.
1153 .\"O The
1154 .\"O .B m
1155 .\"O modifier has the following advantages:
1156 ¥Ð¡¼¥¸¥ç¥ó 2.7 °Ê¹ß¤Ç¤Ï¡¢glibc ¤Ï
1157 .B a
1158 ½¤¾þ»Ò¤ÈƱ¤¸ÌÜŪ¤Ç
1159 .B m
1160 ½¤¾þ»Ò¤âÄ󶡤·¤Æ¤¤¤ë¡£
1161 .B m
1162 ½¤¾þ»Ò¤Ï°Ê²¼¤ÎÍøÅÀ¤¬¤¢¤ë¡£
1163 .IP * 2
1164 .\"O It may also be applied to
1165 .\"O .B %c
1166 .\"O conversion specifiers (e.g.,
1167 .\"O .BR %3mc ).
1168 .B %c
1169 ÊÑ´¹»ØÄê»Ò¤Ë¤âŬÍѤǤ­¤ë (Î㤨¤Ð
1170 .BR %3mc )¡£
1171 .IP *
1172 .\"O It avoids ambiguity with respect to the
1173 .\"O .B %a
1174 .\"O floating-point conversion specifier (and is unaffected by
1175 .\"O .IR "gcc -std=c99"
1176 .\"O etc.)
1177 ÉâÆ°¾®¿ôÅÀÊÑ´¹»ØÄê»Ò¤È¤·¤Æ¤Î
1178 .B %a
1179 ¤È¤Îʶ¤é¤ï¤·¤µ¤¬Èò¤±¤é¤ì¤ë (¤Þ¤¿
1180 .I "gcc -std=c99"
1181 ¤Ê¤É¤Î±Æ¶Á¤âÈò¤±¤é¤ì¤ë)¡£
1182 .IP *
1183 .\"O It is specified in the upcoming revision of the POSIX.1 standard.
1184 POSIX.1 É¸½à¤Î¼¡¤Î²þÄûÈǤǵ¬Äꤵ¤ì¤ë¡£
1185 .\"O .SH BUGS
1186 .SH ¥Ð¥°
1187 .\"O All functions are fully C89 conformant, but provide the
1188 .\"O additional specifiers
1189 .\"O .B q
1190 .\"O and
1191 .\"O .B a
1192 .\"O as well as an additional behavior of the
1193 .\"O .B L
1194 .\"O and
1195 .\"O .B l
1196 .\"O specifiers.
1197 .\"O The latter may be considered to be a bug, as it changes the
1198 .\"O behavior of specifiers defined in C89.
1199 Á´¤Æ¤Î´Ø¿ô¤Ï¡¢´°Á´¤Ë C89 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£¤·¤«¤·
1200 ÄɲäÇ
1201 .B q
1202 ¤È
1203 .B a
1204 »ØÄê»Ò¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢Æ±ÍͤË
1205 .B L
1206 ¤È
1207 .B l
1208 »ØÄê»Ò¤ÎÉÕ²ÃŪ¤Ê¿¶¤ëÉñ¤¤¤â¤¢¤ë¡£¸å¼Ô¤Ï¡¢
1209 C89 ¤ÇÄêµÁ¤µ¤ì¤¿»ØÄê»Ò¤Î¿¶¤ëÉñ¤¤¤òÊѹ¹¤¹¤ë¤â¤Î¤Ê¤Î¤Ç¡¢
1210 ¥Ð¥°¤È¤ß¤Ê¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1211 .PP
1212 .\"O Some combinations of the type modifiers and conversion
1213 .\"O specifiers defined by ANSI C do not make sense
1214 .\"O (e.g.
1215 .\"O .BR "%Ld" ).
1216 ANSI C ¤ÇÄêµÁ¤µ¤ì¤¿·¿½¤¾þ»Ò¤ÈÊÑ´¹»ØÄê»Ò¤ÎÁȤ߹ç¤ï¤»¤ÎÃæ¤Ë¤Ï
1217 °ÕÌ£¤ò¤Ê¤µ¤Ê¤¤¤â¤Î¤¬¤¢¤ë
1218 (Î㤨¤Ð¡¢
1219 .BR "%Ld" )¡£
1220 .\"O While they may have a well-defined behavior on Linux, this need not
1221 .\"O to be so on other architectures.
1222 .\"O Therefore it usually is better to use
1223 .\"O modifiers that are not defined by ANSI C at all, that is, use
1224 .\"O .B q
1225 .\"O instead of
1226 .\"O .B L
1227 .\"O in combination with
1228 .\"O \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, and \fBX\fP
1229 .\"O conversions or
1230 .\"O .BR ll .
1231 ¤³¤ì¤é¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
1232 Linux ¾å¤Ç¤Ï¤Ï¤Ã¤­¤ê¤ÈÄêµÁ¤µ¤ì¤¿¿¶¤ëÉñ¤¤¤ò¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¤¬¡¢
1233 ¾¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤âƱÍͤˤʤäƤ¤¤ë¤È¤Ï¸Â¤é¤Ê¤¤¡£
1234 ¤½¤ì¤æ¤¨¤Ë¡¢¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢
1235 ANSI C ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤½¤¾þ»Ò¤ò»ÈÍѤ·¤¿Êý¤¬Îɤ¤¡£
1236 ¤¹¤Ê¤ï¤Á¡¢
1237 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP
1238 ÊÑ´¹¤ä
1239 .B ll
1240 ¤ÈÁȤ߹ç¤ï¤»¤ë¾ì¹ç¤Ë¤Ï¡¢
1241 .B L
1242 ¤ÎÂå¤ï¤ê¤Ë
1243 .B q
1244 ¤ò»ÈÍѤ·¤¿Êý¤¬Îɤ¤¡£
1245 .PP
1246 .\"O The usage of
1247 .\"O .B q
1248 .\"O is not the same as on 4.4BSD,
1249 .\"O as it may be used in float conversions equivalently to
1250 .\"O .BR L .
1251 .B q
1252 ¤Î»ÈÍÑÊýË¡¤Ï 4.4BSD ¤ÈƱ¤¸¤Ç¤Ï¤Ê¤¤¡£
1253 4.4BSD ¤Ç¤Ï
1254 .B q
1255 ¤Ï
1256 .B L
1257 ¤ÈƱÅù¤ËÉâÆ°¾®¿ô¤ÎÊÑ´¹¤Ë»ÈÍѤµ¤ì¤ë¡£
1258 .\"O .SH "SEE ALSO"
1259 .SH ´ØÏ¢¹àÌÜ
1260 .BR getc (3),
1261 .BR printf (3)
1262 .BR setlocale (3),
1263 .BR strtod (3),
1264 .BR strtol (3),
1265 .BR strtoul (3),