1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
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.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
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.
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
36 .\" @(#)scanf.3 6.14 (Berkeley) 1/8/93
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.
47 .\" Add ERRORS section.
48 .\" Document the 'a' and 'm' modifiers for dynamic string allocation.
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
57 .\"WORD: conversion specifications 変換指定
58 .\"WORD: type modifier 型修飾子
60 .TH SCANF 3 2011-09-28 "GNU" "Linux Programmer's Manual"
63 .\"O scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion
64 scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- 書式付き入力変換
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 ", ...);"
74 .B #include <stdarg.h>
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 );
82 .\"O Feature Test Macro Requirements for glibc (see
83 .\"O .BR feature_test_macros (7)):
85 .RB ( feature_test_macros (7)
94 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
95 _POSIX_C_SOURCE\ >=\ 200112L;
105 .\"O family of functions scans input according to
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
113 .\"O arguments that follow
117 .\"O argument must be of a type that is appropriate for the value returned
118 .\"O by the corresponding conversion specification.
124 .I "「変換指定」 (conversion specifications)"
125 を含めることができ、変換指定があれば、その変換の結果は
135 .\"O If the number of conversion specifications in
137 .\"O exceeds the number of
139 .\"O arguments, the results are undefined.
140 .\"O If the number of
142 .\"O arguments exceeds the number of conversion specifications, then the excess
144 .\"O arguments are evaluated, but are otherwise ignored.
148 引き数の数より多かった場合の結果は未定義である。
150 引き数の数が変換指定の個数よりも多かった場合、
153 引き数の評価は行われるが、それ以外は行われず無視される。
157 .\"O function reads input from the standard input stream
160 .\"O reads input from the stream pointer
164 .\"O reads its input from the character string pointed to by
181 .\"O function is analogous to
182 .\"O .BR vfprintf (3)
183 .\"O and reads input from the stream pointer
185 .\"O using a variable argument list of pointers (see
192 からの入力をポインタの可変長引き数リストを用いて読み込む
197 .\"O function scans a variable argument list from the standard input and the
199 .\"O function scans it from a string; these are analogous to the
202 .\"O .BR vsprintf (3)
203 .\"O functions respectively.
205 関数は、可変長引き数のリストに基づき標準入力からの読み取りを行う。
207 関数はそのリストに基づき文字列から読み取る。
216 .\"O string consists of a sequence of
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
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).
229 .I "「命令」 (directive)"
230 の列で構成される。命令は入力文字の系列をどのように処理するかを指示する
231 ものである。ある命令の処理が失敗すると、入力はそれ以上読み込まれず、
234 .I "「入力の失敗」 (input failure)"
236 .I "「一致の失敗」 (matching failure)"
238 入力の失敗は入力文字が使用できなかったことを意味し、
239 一致の失敗は入力が不適切であったこと (下記参照) を意味する。
241 .\"O A directive is one of the following:
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 ホワイトスペース (スペース、タブ、改行など;
252 この命令は、入力中の任意の個数のホワイトスペースに一致する。
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 この文字は入力の次の文字に正確に一致しなければならない。
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
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 入力された文字の系列はこの指定にもとづいて変換され、
276 入力の次の文字が変換指定と一致しない場合は、変換は失敗する
278 .I "「一致の失敗」 (matching failure)"
282 .\"O .I conversion specification
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:
291 は文字 \(aq%\(aq か文字系列 "\fB%\fP\fIn\fP\fB$\fP"
292 (違いについては後述) で始まり、以下の要素が続く。
295 .\"O An optional \(aq*\(aq assignment-suppression character:
297 .\"O reads input as directed by the conversion specification,
298 .\"O but discards the input.
299 .\"O No corresponding
301 .\"O argument is required, and this specification is not
302 .\"O included in the count of successful assignments returned by
304 代入抑制文字 \(aq*\(aq (省略可能)。
306 は変換指定に指示された通り入力を読み込むが、その入力は捨てられる。
311 が返す代入が成功した数にこの指定は含まれない。
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,
318 .\"O allocates a buffer of sufficient size,
319 .\"O and assigns the address of this buffer to the corresponding
321 .\"O argument, which should be a pointer to a
323 .\"O variable (this variable does not need to be initialized before the call).
324 .\"O The caller should subsequently
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 呼び出し元が入力を保持する対応するバッファを確保する必要がなくなる。
334 が必要な大きさのバッファを確保し、このバッファのアドレスを
342 (変数自体は呼び出し前に初期化されている必要はない)。
343 呼び出し元は、不要になった時点で、このバッファを
345 すべきである。この機能は GNU による拡張である。
346 C99 は \(aqa\(aq 文字を変換指定として使用している
347 (こちらも GNU の実装と同じように使用することができる)。
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.
362 この最大値に達するか、一致しない文字が見つかるか、のどちらかに
364 ほとんどの変換では、先頭のホワイトスペース文字は捨てられ
366 捨てられたこれらの文字は最大フィールド幅の計算には含まれない。
367 文字列の入力変換では、入力の末尾を示す終端の NULL バイト (\(aq\\0\(aq)
368 も格納されるが、最大フィールド幅にはこの終端バイトは含まれない。
372 .\"O .IR "type modifier character" .
373 .\"O For example, the
375 .\"O type modifier is used with integer conversions such as
377 .\"O to specify that the corresponding
379 .\"O argument refers to a
381 .\"O rather than a pointer to an
383 .I "「型修飾子」 (type modifier characters)"
399 .\"O .I "conversion specifier"
400 .\"O that specifies the type of input conversion to be performed.
404 .\"O The conversion specifications in
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
410 .\"O string, except that a string containing
411 .\"O "\fB%\fP\fIn\fP\fB$\fP"
412 .\"O specifications can include
417 中の変換指定は、\(aq%\(aq で始まるか、
418 "\fB%\fP\fIn\fP\fB$\fP" で始まるかの、いずれかの形式である。
421 文字列に混ぜることはできない。但し、"\fB%\fP\fIn\fP\fB$\fP" を
429 .\"O contains \(aq%\(aq
430 .\"O specifications then these correspond in order with successive
434 に \(aq%\(aq 指定が含まれている場合、各々の \(aq%\(aq 指定と
439 .\"O "\fB%\fP\fIn\fP\fB$\fP"
440 .\"O form (which is specified in POSIX.1-2001, but not C99),
442 .\"O is a decimal integer that specifies that the converted input should
443 .\"O be placed in the location referred to by the
446 .\"O argument following
448 "\fB%\fP\fIn\fP\fB$\fP" 形式
449 (POSIX.1-2001 では規定されているが、C99 にはない)
458 引き数が参照する場所に格納することを指定する。
462 .\"O .I "type modifier characters"
463 .\"O can appear in a conversion specification:
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
474 .\"O .I unsigned short int
478 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, \fBn\fP
484 .I unsigned short int
490 .\"O but the next pointer is a pointer to a
493 .\"O .IR "unsigned char" .
504 .\"O but the next pointer is a pointer to an
508 .\"O This modifier was introduced in C99.
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
523 .\"O .I unsigned long 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
533 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, \fBn\fP
543 \fBe\fP, \fBf\fP, \fBg\fP
548 へのポインタであることのいずれかであることを示す。
551 .\"O characters is equivalent to
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.
568 パラメータはそれぞれワイド文字やワイド文字列へのポインタであると
570 .\" l のこの使用法は ISO C90 の Amendment 1 で導入された。
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
585 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP
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
593 .\"O .\" type. Any program using this will not be portable to all
594 .\"O .\" architectures).
595 .\" MTK, Jul 05: 以下の内容は新しい ANSI C (つまり C99) では
599 .\" で規定された型ではないことに注意しよう。
600 .\" これを用いたプログラムは全てのアーキテクチャに対して
606 .\"O This specifier does not exist in ANSI C.
609 この修飾子は ANSI C には存在しない。
614 .\"O but the next pointer is a pointer to a
616 .\"O This modifier was introduced in C99.
626 .\"O but the next pointer is a pointer to a
628 .\"O This modifier was introduced in C99.
636 .\"O .I "conversion specifiers"
643 .\"O Matches a literal \(aq%\(aq.
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.
653 は単一の文字 \(aq%\(aq に対応する。
654 変換は行われず (但し、先頭のホワイトスペース文字は捨てられる)、
658 .\"O Matches an optionally signed decimal integer;
659 .\"O the next pointer must be a pointer to
669 .\"O this exists only for backward compatibility.
670 .\"O (Note: thus only in libc4.
671 .\"O In libc5 and glibc the
673 .\"O is silently ignored, causing old programs to fail mysteriously.)
675 と同一である。これは以前の仕様との互換性だけのためにある。
676 (注意: これは libc4 の場合だけである。 libc5 や glibc では
678 は暗黙のうちに無視され、古いプログラムにおいて謎に満ちた失敗の原因となる。)
681 .\"O Matches an optionally signed integer; the next pointer must be a pointer to
683 .\"O The integer is read in base 16 if it begins with
687 .\"O in base 8 if it begins with
689 .\"O and in base 10 otherwise.
690 .\"O Only characters that correspond to the base are used.
701 で開始する場合には 8 進数、その他の場合には 10進数として読み込まれる。
702 この変換で使用される文字は、これらの基数に対応しているものだけである。
705 .\"O Matches an unsigned octal integer; the next pointer must be a pointer to
706 .\"O .IR "unsigned int" .
713 .\"O Matches an unsigned decimal integer; the next pointer must be a
715 .\"O .IR "unsigned int" .
722 .\"O Matches an unsigned hexadecimal integer; the next pointer must
724 .\"O .IR "unsigned int" .
737 .\"O Matches an optionally signed floating-point number; the next pointer must
764 .\"O (C99) Equivalent to
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 達するか、のどちらかが起こると停止される。
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
789 .\"O and there must be enough room for all the characters (no terminating
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.
795 (デフォルトは 1) で指定された幅の文字の列に対応する。
798 へのポインタで、すべての文字を格納するのに十分な領域が
799 なければならない (終端の NULL バイトは追加されない)。
800 通常行われる先頭のホワイトスペースの読み飛ばしは行われない。
801 先頭のホワイトスペースを読み飛ばすためには、
802 フォーマット文の中で明示的にスペースを使用すれば良い。
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
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.
812 指定された文字の集合で構成される空ではない文字の列に対応する。
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
822 .\"O character and a close bracket
827 .\"O those characters if the first character after the open bracket is a
830 この文字列は特別な集合の中の文字で構成されている。
837 開き括弧のあとの最初の文字が曲アクセント記号
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
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 つまり、他の位置に閉じ括弧を置くと文字の集合が終る。
854 二つの異なる文字の間に置かれた時、この文字は、
857 括弧が閉じる前の最後の一文字をハイフンにすればよい。
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.
866 は「閉じ括弧、0 〜 9、ハイフンの 3 種類を除く全ての文字」の集合を意味する。
868 集合に含まれていない (曲アクセントの場合には含まれる) 文字の
869 出現または確保された領域が使い切られた時に終了する。
872 .\"O Matches a pointer value (as printed by
876 .\"O the next pointer must be a pointer to a pointer to
881 で印字されるような) ポインタ値に対応する。
884 へのポインタへのポインタでなければならない。
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
893 入力からここまで消費された文字数が次のポインタで指定された場所に
900 .\"O a conversion, although it can be suppressed with the
902 .\"O assignment-suppression character.
905 代入抑制文字を使って抑制することができるのだが、
907 .\"O The C standard says: "Execution of a
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
915 .\"O conversions on the return value.
916 C 言語の標準規格では「実行の完了時に返される代入の回数は
918 命令の実行では増加しない」となっているが、
919 正誤表の内容はこれと矛盾するようである。おそらく、
921 変換が返り値に与える影響についてはどのような仮定もしないのが
923 .\"O .SH "RETURN VALUE"
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 になることもある。
935 .\"O is returned if the end of input is reached before either the first
936 .\"O successful conversion or a matching failure occurs.
938 .\"O is also returned if a read error occurs,
939 .\"O in which case the error indicator for the stream (see
943 .\"O is set indicate the error.
944 最初の変換が成功する前に入力の最後に達して、一致の失敗が起こった場合には、
949 が返される。読み込みエラーの場合には、そのストリームの
959 .\"O The file descriptor underlying
961 .\"O is marked nonblocking, and the read operation would block.
963 に対応するファイルディスクリプタが nonblocking となっており、
964 読み込み操作は停止 (block) することになる。
967 .\"O The file descriptor underlying
969 .\"O is invalid, or not open for reading.
971 に対応するファイルディスクリプタが無効であるが、
975 .\"O Input byte sequence does not form a valid character.
976 入力されたバイト列が有効な文字を構成していない。
979 .\"O The read operation was interrupted by a signal; see
981 読み込み操作がシグナルにより割り込まれた。
986 .\"O Not enough arguments; or
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"
1008 .\"O conform to C89 and C99 and POSIX.1-2001.
1009 .\"O These standards do not specify the
1015 関数は C89, C99, POSIX.1-2001 に準拠している。
1022 .\"O specifier is the 4.4BSD notation for
1023 .\"O .IR "long long" ,
1030 .\"O or the usage of
1032 .\"O in integer conversions is the GNU notation.
1039 .\"O The Linux version of these functions is based on the
1043 .\"O Take a look at the
1045 .\"O documentation of
1047 .\"O .I libc (glibc-1.08)
1048 .\"O for a more concise description.
1055 .I libc (glibc-1.08)
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
1066 .\"O \fB%a[\fP\fIrange\fP\fB]\fP
1067 .\"O conversion specifiers.
1068 GNU C ライブラリ (glibc) では非標準のオプションをサポートしており、
1072 \fB%a[\fP\fIrange\fP\fB]\fP
1073 への入力文字列に対して十分な大きさの文字列をライブラリが動的に確保する
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
1079 .\"O as a length modifier (thus
1082 .\"O \fB%a[\fP\fIrange\fP\fB]\fP).
1083 .\"O The caller must
1085 .\"O the returned string, as in the following example:
1086 この機能を使用するには、長さ修飾子として
1091 \fB%a[\fP\fIrange\fP\fB]\fP となる)。
1092 以下の例にあるように、呼び出し側は返された文字列を
1102 n = scanf("%a[a-z]", &p);
1104 printf("read: %s\\n", p);
1106 } else if (errno != 0) {
1109 fprintf(stderr, "No matching characters\\n"):
1114 .\"O As shown in the above example, it is only necessary to call
1118 .\"O call successfully read a string.
1121 が文字列の読み込みに成功した場合にだけ、
1127 .\"O modifier is not available if the program is compiled with
1128 .\"O .I "gcc -std=c99"
1130 .\"O .IR "gcc -D_ISOC99_SOURCE"
1133 .\"O is also specified), in which case the
1135 .\"O is interpreted as a specifier for floating-point numbers (see above).
1138 .I "gcc -D_ISOC99_SOURCE"
1146 は (上述の通り) 浮動小数点数を示す変換指定子と解釈される。
1148 .\"O Since version 2.7, glibc also provides the
1150 .\"O modifier for the same purpose as the
1155 .\"O modifier has the following advantages:
1156 バージョン 2.7 以降では、glibc は
1164 .\"O It may also be applied to
1166 .\"O conversion specifiers (e.g.,
1172 .\"O It avoids ambiguity with respect to the
1174 .\"O floating-point conversion specifier (and is unaffected by
1175 .\"O .IR "gcc -std=c99"
1183 .\"O It is specified in the upcoming revision of the POSIX.1 standard.
1184 POSIX.1 標準の次の改訂版で規定される。
1187 .\"O All functions are fully C89 conformant, but provide the
1188 .\"O additional specifiers
1192 .\"O as well as an additional behavior of the
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 に準拠している。しかし
1208 指定子の付加的な振る舞いもある。後者は、
1209 C89 で定義された指定子の振る舞いを変更するものなので、
1212 .\"O Some combinations of the type modifiers and conversion
1213 .\"O specifiers defined by ANSI C do not make sense
1216 ANSI C で定義された型修飾子と変換指定子の組み合わせの中には
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
1227 .\"O in combination with
1228 .\"O \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, and \fBX\fP
1232 Linux 上でははっきりと定義された振る舞いをするかもしれないが、
1233 他のアーキテクチャでも同様になっているとは限らない。
1235 ANSI C で定義されていない修飾子を使用した方が良い。
1237 \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP
1248 .\"O is not the same as on 4.4BSD,
1249 .\"O as it may be used in float conversions equivalently to
1252 の使用方法は 4.4BSD と同じではない。