.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" References consulted:
.\" Linux libc source code
.\" 386BSD man pages
.\" Modified Sun Jul 25 10:53:39 1993 by Rik Faith (faith@cs.unc.edu)
.\" Added correction due to nsd@bbc.com (Nick Duffek) - aeb, 950610
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
.\"
.\" Japanese Version Copyright (c) 1999 AKAMATSU, Kazuo
.\" all rights reserved.
.\" Updated Sat Mar 23 JST 2002 by Kentaro Shirakata <argrath@ub32.org>
.\" Updated & Modified 2006-07-20,
.\" Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
+.\" Updated 2012-05-04, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.\" WORD: base ´ð¿ô
-.\"
-.TH STRTOL 3 2007-07-26 "GNU" "Linux Programmer's Manual"
-.SH ̾Á°
-.\"O strtol, strtoll, strtoq \- convert a string to a long integer
-strtol, strtoll, strtoq \- ʸ»úÎó¤ò long int ¤ËÊÑ´¹¤¹¤ë
-.SH ½ñ¼°
+.TH STRTOL 3 2014\-03\-18 GNU "Linux Programmer's Manual"
+.SH 名前
+strtol, strtoll, strtoq \- 文字列を long int に変換する
+.SH 書式
.nf
-.B #include <stdlib.h>
+\fB#include <stdlib.h>\fP
.sp
-.BI "long int strtol(const char *" nptr ", char **" endptr ", int " base );
+\fBlong int strtol(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB, int \fP\fIbase\fP\fB);\fP
.sp
-.BI "long long int strtoll(const char *" nptr ", char **" endptr \
-", int " base );
+\fBlong long int strtoll(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB, int \fP\fIbase\fP\fB);\fP
.fi
.sp
.in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
.in
.sp
.ad l
-.BR strtoll ():
-XOPEN_SOURCE >= 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE; or
-.I cc\ -std=c99
-.ad b
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The
-.\"O .BR strtol ()
-.\"O function converts the initial part of the string
-.\"O in \fInptr\fP to a long integer value according to the given \fIbase\fP,
-.\"O which must be between 2 and 36 inclusive, or be the special value 0.
-.BR strtol ()
-´Ø¿ô¤Ï¡¢ \fInptr\fP ¤Îʸ»úÎó¤ÎºÇ½é¤ÎÉôʬ¤ò¡¢
-\fIbase\fP ¤ò´ð¿ô¤È¤·¤Æ long int ¤ËÊÑ´¹¤¹¤ë¡£
-¤³¤Î \fIbase\fP ¤Ï 2 ¤«¤é 36 ¤Þ¤Ç¤ÎÃÍ
-¤¢¤ë¤¤¤ÏÆÃÊ̤ʰÕÌ£¤ò»ý¤ÄÃÍ 0 ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
+\fBstrtoll\fP():
+.RS 4
+XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE
+|| _POSIX_C_SOURCE\ >=\ 200112L;
+.br
+または \fIcc\ \-std=c99\fP
+.RE
+.ad
+.SH 説明
+\fBstrtol\fP() 関数は、 \fInptr\fP の文字列の最初の部分を、 \fIbase\fP を基数として long int に変換する。 この
+\fIbase\fP は 2 から 36 までの値 あるいは特別な意味を持つ値 0 でなければならない。
.PP
-.\"O The string may begin with an arbitrary amount of white space (as
-.\"O determined by
-.\"O .BR isspace (3))
-.\"O followed by a single optional \(aq+\(aq or \(aq\-\(aq sign.
-.\"O If \fIbase\fP is zero or 16, the string may then include a
-.\"O "0x" prefix, and the number will be read in base 16; otherwise, a
-.\"O zero \fIbase\fP is taken as 10 (decimal) unless the next character
-.\"O is \(aq0\(aq, in which case it is taken as 8 (octal).
-ʸ»úÎó¤ÎÀèƬ¤Ë¤Ï¡¢Ç¤°Õ¤Î¿ô¤Î¶õÇò¤¬¤¢¤Ã¤Æ¤â¤è¤¯ (¶õÇò¤Ï
-.BR isspace (3)
-¤ÇȽÄꤵ¤ì¤ë)¡¢¤Þ¤¿¿ô»ú¤ÎľÁ°¤Ë¤Ï \(aq+\(aq ¤« \(aq\-\(aq ¤Î
-Éä¹æ¤¬¤¢¤Ã¤Æ¤â¤è¤¤¡£
-\fIbase\fP ¤¬ 0 ¤Þ¤¿¤Ï 16 ¤Î¾ì¹ç¤Ë¤Ï¡¢Ê¸»úÎó¤ÎÀèƬ¤Ë "0x" ¤òÃÖ¤¯¤³¤È¤¬
-¤Ç¤¡¢¤½¤Î¾ì¹ç¤Ë¤Ïʸ»úÎó¤Ï 16¿Ê¿ô¤È¤·¤Æ°·¤ï¤ì¤ë¡£
-¤³¤ì°Ê³°¤Îʸ»úÎó¤Ç \fIbase\fP ¤¬ 0 ¤Î¾ì¹ç¤Ï¡¢
-ʸ»úÎó¤¬ \(aq0\(aq ¤Ç»Ï¤Þ¤ë¤È¤¤Ï 8¿Ê¿ô¤È¤·¤Æ¡¢
-¤½¤ì°Ê³°¤Î¤È¤¤Ï 10¿Ê¿ô¤È¤·¤Æ°·¤ï¤ì¤ë¡£
+文字列の先頭には、任意の数の空白があってもよく (空白は \fBisspace\fP(3) で判定される)、また数字の直前には \(aq+\(aq か
+\(aq\-\(aq の 符号があってもよい。 \fIbase\fP が 0 または 16 の場合には、文字列の先頭に "0x" を置くことが
+でき、その場合には文字列は 16進数として扱われる。 これ以外の文字列で \fIbase\fP が 0 の場合は、 文字列が \(aq0\(aq
+で始まるときは 8進数として、 それ以外のときは 10進数として扱われる。
.PP
-.\"O The remainder of the string is converted to a
-.\"O .I long int
-.\"O value
-.\"O in the obvious manner, stopping at the first character which is not a
-.\"O valid digit in the given base.
-.\"O (In bases above 10, the letter \(aqA\(aq in
-.\"O either upper or lower case represents 10, \(aqB\(aq represents 11, and so
-.\"O forth, with \(aqZ\(aq representing 35.)
-¿ô»ú¤òɽ¤¹Ê¸»úÎó¤Ï
-.I long int
-¤ËÊÑ´¹¤µ¤ì¤ë¤¬¡¢´ð¿ô¤ËÂФ·¤Æ
-͸ú¤Ç¤Ê¤¤¿ô»ú¤¬¸½¤ì¤¿»þÅÀ¤ÇÊÑ´¹¤Ï½ªÎ»¤¹¤ë¡£(11¿Ê¿ô°Ê¾å¤Ç¤Ï \(aqA\(aq ¤Ï
-Âçʸ»ú¡¦¾®Ê¸»ú¤Ë´Ø¤ï¤é¤º 10 ¤òɽ¤·¡¢ \(aqB\(aq ¤Ï 11 ¤òɽ¸½¤·¡¢
-°Ê²¼Æ±Íͤˡ¢ \(aqZ\(aq ¤Ï 35 ¤òɽ¤¹¡£)
+数字を表す文字列は \fIlong int\fP に変換されるが、基数に対して 有効でない数字が現れた時点で変換は終了する。(11進数以上では
+\(aqA\(aq は 大文字・小文字に関わらず 10 を表し、 \(aqB\(aq は 11 を表現し、 以下同様に、 \(aqZ\(aq は 35
+を表す。)
.PP
-.\"O If \fIendptr\fP is not NULL,
-.\"O .BR strtol ()
-.\"O stores the address of the
-.\"O first invalid character in \fI*endptr\fP.
-.\"O If there were no digits at
-.\"O all,
-.\"O .BR strtol ()
-.\"O stores the original value of \fInptr\fP in
-.\"O \fI*endptr\fP (and returns 0).
-\fIendptr\fP ¤¬¥Ì¥ëÃÍ (NULL) ¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢ºÇ½é¤Ë¸½¤ì¤¿ÉÔÀµ¤Êʸ»ú¤¬
-.BR strtol ()
-¤Ë¤è¤Ã¤Æ \fI*endptr\fP ¤ËÊݸ¤µ¤ì¤Æ¤¤¤ë¡£
-ʸ»úÎó¤Ë͸ú¤Ê¿ô»ú¤¬¤Ò¤È¤Ä¤â¤Ê¤±¤ì¤Ð¡¢
-.BR strtol ()
-¤Ï \fInptr\fP
-¤Î¸µ¤ÎÃͤò \fI*endptr\fP ¤ËÂåÆþ¤¹¤ë (¤½¤·¤Æ 0 ¤òÊÖ¤¹)¡£
-.\"O In particular, if \fI*nptr\fP is not \(aq\\0\(aq but \fI**endptr\fP
-.\"O is \(aq\\0\(aq on return, the entire string is valid.
-Æäˡ¢\fI*nptr\fP ¤¬ \(aq\\0\(aq °Ê³°¤Ç¡¢ÊÖ¤µ¤ì¤¿ \fI**endptr\fP ¤¬
-\(aq\\0\(aq ¤Ê¤é¤Ð¡¢Ê¸»úÎóÁ´ÂΤ¬Í¸ú¤À¤Ã¤¿¤³¤È¤Ë¤Ê¤ë¡£
+\fIendptr\fP がヌル値 (NULL) でない場合は、最初に現れた不正な文字が \fBstrtol\fP() によって \fI*endptr\fP
+に保存されている。 文字列に有効な数字がひとつもなければ、 \fBstrtol\fP() は \fInptr\fP の元の値を \fI*endptr\fP に代入する
+(そして 0 を返す)。 特に、\fI*nptr\fP が \(aq\e0\(aq 以外で、返された \fI**endptr\fP が \(aq\e0\(aq
+ならば、文字列全体が有効だったことになる。
.PP
-.\"O The
-.\"O .BR strtoll ()
-.\"O function works just like the
-.\"O .BR strtol ()
-.\"O function but returns a long long integer value.
-.BR strtoll ()
-´Ø¿ô¤Ï
-.BR strtol ()
-¤ÈƱÍͤÀ¤¬¡¢long long int ·¿¤ÎÃͤòÊÖ¤¹¡£
-.SH ÊÖ¤êÃÍ
-.\"O The
-.\"O .BR strtol ()
-.\"O function returns the result of the conversion,
-.\"O unless the value would underflow or overflow.
-.\"O If an underflow occurs,
-.\"O .BR strtol ()
-.\"O returns
-.\"O .BR LONG_MIN .
-.\"O If an overflow occurs,
-.\"O .BR strtol ()
-.\"O returns
-.\"O .BR LONG_MAX .
-.\"O In both cases, \fIerrno\fP is set to
-.\"O .BR ERANGE .
-¥¢¥ó¥À¡¼¥Õ¥í¡¼¤â¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤âµ¯¤¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
-.BR strtol ()
-´Ø¿ô¤Ï
-ÊÑ´¹¤µ¤ì¤¿ÃͤòÊÖ¤¹¡£¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤·¤¿¾ì¹ç¤Ë¤Ï
-.B LONG_MAX
-¤¬Ê֤ꡢ
-¥¢¥ó¥À¡¼¥Õ¥í¡¼¤·¤¿¾ì¹ç¤Ë¤Ï
-.B LONG_MIN
-¤¬Ê֤롣¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¡¢
-¥¢¥ó¥À¡¼¥Õ¥í¡¼¤Î¤¤¤º¤ì¤Î¾ì¹ç¤Ë¤â
-Âç°èÊÑ¿ô \fIerrno\fP ¤Ë¤Ï
-.B ERANGE
-¤¬ÀßÄꤵ¤ì¤ë¡£
-.\"O Precisely the same holds for
-.\"O .BR strtoll ()
-.\"O (with
-.\"O .B LLONG_MIN
-.\"O and
-.\"O .B LLONG_MAX
-.\"O instead of
-.\"O .B LONG_MIN
-.\"O and
-.\"O .BR LONG_MAX ).
-.BR strtoll ()
-¤âƱÍͤǤ¢¤ë¤¬¡¢
-.B LONG_MIN
-¤È
-.B LONG_MAX
-¤ÎÂå¤ï¤ê¤Ë
-.B LLONG_MIN
-¤È
-.B LLONG_MAX
-¤¬ÊÖ¤µ¤ì¤ë¡£
-.SH ¥¨¥é¡¼
-.TP
-.B EINVAL
-.\"O (not in C99)
-.\"O The given
-.\"O .I base
-.\"O contains an unsupported value.
-(C99 ¤Ë¤Ï¤Ê¤¤)
-.I base
-¤¬Âбþ¤·¤Æ¤¤¤Ê¤¤ÃͤǤ¢¤ë¡£
-.TP
-.B ERANGE
-.\"O The resulting value was out of range.
-·ë²Ì¤ÎÃͤ¬Èϰϳ°¤Ç¤¢¤ë¡£
+\fBstrtoll\fP() 関数は \fBstrtol\fP() と同様だが、long long int 型の値を返す。
+.SH 返り値
+アンダーフローもオーバーフローも起きなかった場合、 \fBstrtol\fP() 関数は 変換された値を返す。オーバーフローした場合には
+\fBLONG_MAX\fP が返り、 アンダーフローした場合には \fBLONG_MIN\fP が返る。オーバーフロー、 アンダーフローのいずれの場合にも
+大域変数 \fIerrno\fP には \fBERANGE\fP が設定される。 \fBstrtoll\fP() も同様であるが、 \fBLONG_MIN\fP と
+\fBLONG_MAX\fP の代わりに \fBLLONG_MIN\fP と \fBLLONG_MAX\fP が返される。
+.SH エラー
+.TP
+\fBEINVAL\fP
+(C99 にはない) 指定された \fIbase\fP がサポートされていない値である。
+.TP
+\fBERANGE\fP
+結果の値が範囲外である。
.LP
-.\"O The implementation may also set \fIerrno\fP to \fBEINVAL\fP in case
-.\"O no conversion was performed (no digits seen, and 0 returned).
-¼ÂÁõ¤Ë¤è¤Ã¤Æ¤Ï¡¢ÊÑ´¹¤¬¹Ô¤ï¤ì¤Ê¤«¤Ã¤¿¾ì¹ç (¿ô»ú¤¬¤Ê¤¯¡¢0 ¤òÊÖ¤·¤¿¾ì¹ç)¡¢
-\fIerrno\fP ¤Ë \fBEINVAL\fP ¤¬ÀßÄꤵ¤ì¤ë¾ì¹ç¤¬¤¢¤ë¡£
-.SH ½àµò
-.\"O .BR strtol ()
-.\"O conforms to SVr4, 4.3BSD, C89, C99 and POSIX.1-2001, and
-.\"O .BR strtoll ()
-.\"O to C99 and POSIX.1-2001.
-.BR strtol ()
-¤Ï SVr4, 4.3BSD, C89, C99 ¤È POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
-.BR strtoll ()
-¤Ï C99 ¤È POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O Since
-.\"O .BR strtol ()
-.\"O can legitimately return 0,
-.\"O .BR LONG_MAX ,
-.\"O or
-.\"O .B LONG_MIN
-.\"O .RB ( LLONG_MAX
-.\"O or
-.\"O .B LLONG_MIN
-.\"O for
-.\"O .BR strtoll ())
-.\"O on both success and failure, the calling program should set
-.\"O .I errno
-.\"O to 0 before the call,
-.\"O and then determine if an error occurred by checking whether
-.\"O .I errno
-.\"O has a nonzero value after the call.
-.B strtol ()
-¤«¤é¤ÏÀ®¸ù¡¢¼ºÇԤɤÁ¤é¤Î¾ì¹ç¤Ç¤â
-0,
-.BR LONG_MAX ,
-.B LONG_MIN
-.RB ( strtoll ()
-¤Ç¤Ï
-.BR LLONG_MAX ,
-.BR LLONG_MIN )
-¤¬ÊÖ¤ë²ÄǽÀ¤¬¤¢¤ë¤Î¤Ç¡¢
-¥×¥í¥°¥é¥à¤Ï´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë
-.I errno
-¤ò 0 ¤ËÀßÄꤷ¡¢¸Æ¤Ó½Ð¤·¸å¤Ë
-.I errno
-¤¬ 0 °Ê³°¤ÎÃͤ«¤É¤¦¤«¤ò³Îǧ¤·¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤«¤É¤¦¤«¤òȽÃǤ¹¤ë
-ɬÍפ¬¤¢¤ë¡£
+実装によっては、変換が行われなかった場合 (数字がなく、0 を返した場合)、 \fIerrno\fP に \fBEINVAL\fP が設定される場合がある。
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+関数 \fBstrtol\fP(), \fBstrtoll\fP(), \fBstrtoq\fP() は、例外付きのスレッドセーフである。実行中に
+\fBsetlocale\fP(3) を呼び出してロケールを変更しない限り、マルチスレッドアプリケーションで安全に使用することができる。
+.SH 準拠
+\fBstrtol\fP() は SVr4, 4.3BSD, C89, C99 と POSIX.1\-2001 に準拠している。 \fBstrtoll\fP()
+は C99 と POSIX.1\-2001 に準拠している。
+.SH 注意
+\fBstrtol ()\fP からは成功、失敗どちらの場合でも 0, \fBLONG_MAX\fP, \fBLONG_MIN\fP (\fBstrtoll\fP() では
+\fBLLONG_MAX\fP, \fBLLONG_MIN\fP) が返る可能性があるので、 プログラムは関数を呼び出す前に \fIerrno\fP を 0
+に設定し、呼び出し後に \fIerrno\fP が 0 以外の値かどうかを確認しエラーが発生したかどうかを判断する 必要がある。
-.\"O In locales other than the "C" locale, other strings may also be accepted.
-.\"O (For example, the thousands separator of the current locale may be
-.\"O supported.)
-"C" °Ê³°¤Î¥í¥±¡¼¥ë¤Î¾ì¹ç¡¢¤½¤Î¾¤Îʸ»úÎó¤â¼õ¤±ÉÕ¤±¤é¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-(Î㤨¤Ð¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤Î 1000 Ëè¤Î¶èÀÚ¤êʸ»ú¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£)
+POSIX.1\-2001 では、 "C" と "POSIX"
+以外のロケールでは、これらの関数は、他の実装時に定義される数字を示す文字列を受け付けるとされている。
.LP
-.\"O BSD also has
-BSD ¤Ë¤Ï¡¢
+BSD には、
.sp
.in +4n
.nf
-.BI "quad_t strtoq(const char *" nptr ", char **" endptr ", int " base );
+\fBquad_t strtoq(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB, int \fP\fIbase\fP\fB);\fP
.sp
.in
.fi
-.\"O with completely analogous definition.
-¤È¤¤¤¦´°Á´¤ËƱÍͤÎÄêµÁ¤ò»ý¤Ä´Ø¿ô¤¬¤¢¤ë¡£
-.\"O Depending on the wordsize of the current architecture, this
-.\"O may be equivalent to
-.\"O .BR strtoll ()
-.\"O or to
-.\"O .BR strtol ().
-»ÈÍÑÃæ¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Î¥ï¡¼¥ÉĹ¼¡Âè¤Ç¤¢¤ë¤¬¡¢¤³¤Î´Ø¿ô¤Ï
-.BR strtoll ()
-¤«
-.BR strtol ()
-¤ÈÅù²Á¤È¤Ê¤ë¤³¤È¤â¤¢¤ë¡£
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O The program shown below demonstrates the use of
-.\"O .BR strtol ().
-.\"O The first command-line argument specifies a string from which
-.\"O .BR strtol ()
-.\"O should parse a number.
-.\"O The second (optional) argument specifies the base to be used for
-.\"O the conversion.
-.\"O (This argument is converted to numeric form using
-.\"O .BR atoi (3),
-.\"O a function that performs no error checking and
-.\"O has a simpler interface than
-.\"O .BR strtol ().)
-°Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
-.BR strtol ()
-¤Î»ÈÍÑÎã¤Ç¤¢¤ë¡£
-ºÇ½é¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤Ë¤Ï
-.BR strtol ()
-¤¬¿ô»ú¤È¤·¤Æ²ò¼á¤¹¤ëʸ»úÎó¤ò»ØÄꤹ¤ë¡£
-(¾Êά²Äǽ¤Ê) ÆóÈÖÌܤΰú¤¿ô¤Ë¤Ï
-ÊÑ´¹¤Ë»ÈÍѤµ¤ì¤ë´ð¿ô¤ò»ØÄꤹ¤ë
-(¤³¤Î°ú¤¿ô¤Ï
-.BR atoi (3)
-¤ò»È¤Ã¤Æ¿ôÃͤËÊÑ´¹¤µ¤ì¤ë¡£
-.BR atoi (3)
-¤Ï
-.BR strtol ()
-¤è¤ê¤â´Êñ¤Ê¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò»ý¤Ä´Ø¿ô¤Ç¡¢
-¤½¤ÎÃæ¤Ç¤Ï¥¨¥é¡¼¥Á¥§¥Ã¥¯¤Ï¹Ô¤ï¤ì¤Ê¤¤)¡£
-.\"O Some examples of the results produced by this program are the following:
-¤³¤Î¥×¥í¥°¥é¥à¤Î¼Â¹ÔÎã¤ò¤¤¤¯¤Ä¤«°Ê²¼¤Ë¼¨¤¹:
+という完全に同様の定義を持つ関数がある。 使用中のアーキテクチャのワード長次第であるが、この関数は \fBstrtoll\fP() か
+\fBstrtol\fP() と等価となることもある。
+.SH 例
+以下のプログラムは \fBstrtol\fP() の使用例である。 最初のコマンドライン引き数には \fBstrtol\fP()
+が数字として解釈する文字列を指定する。 (省略可能な) 二番目の引き数には 変換に使用される基数を指定する (この引き数は \fBatoi\fP(3)
+を使って数値に変換される。 \fBatoi\fP(3) は \fBstrtol\fP() よりも簡単なインタフェースを持つ関数で、
+その中ではエラーチェックは行われない)。 このプログラムの実行例をいくつか以下に示す:
.in +4n
.nf
-.RB "$" " ./a.out 123"
+$\fB ./a.out 123\fP
strtol() returned 123
-.RB "$" " ./a.out \(aq 123\(aq"
+$\fB ./a.out \(aq 123\(aq\fP
strtol() returned 123
-.RB "$" " ./a.out 123abc"
+$\fB ./a.out 123abc\fP
strtol() returned 123
Further characters after number: abc
-.RB "$" " ./a.out 123abc 55"
+$\fB ./a.out 123abc 55\fP
strtol: Invalid argument
-.RB "$" " ./a.out \(aq\(aq"
+$\fB ./a.out \(aq\(aq\fP
No digits were found
-.RB "$" " ./a.out 4000000000"
+$\fB ./a.out 4000000000\fP
strtol: Numerical result out of range
.fi
.in
-.\"O .SS Program source
-.SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
+.SS プログラムのソース
\&
.nf
#include <stdlib.h>
long val;
if (argc < 2) {
- fprintf(stderr, "Usage: %s str [base]\\n", argv[0]);
+ fprintf(stderr, "Usage: %s str [base]\en", argv[0]);
exit(EXIT_FAILURE);
}
}
if (endptr == str) {
- fprintf(stderr, "No digits were found\\n");
+ fprintf(stderr, "No digits were found\en");
exit(EXIT_FAILURE);
}
/* If we got here, strtol() successfully parsed a number */
- printf("strtol() returned %ld\\n", val);
+ printf("strtol() returned %ld\en", val);
- if (*endptr != \(aq\\0\(aq) /* Not necessarily an error... */
- printf("Further characters after number: %s\\n", endptr);
+ if (*endptr != \(aq\e0\(aq) /* Not necessarily an error... */
+ printf("Further characters after number: %s\en", endptr);
exit(EXIT_SUCCESS);
}
.fi
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR atof (3),
-.BR atoi (3),
-.BR atol (3),
-.BR strtod (3),
-.BR strtoul (3)
+.SH 関連項目
+\fBatof\fP(3), \fBatoi\fP(3), \fBatol\fP(3), \fBstrtod\fP(3), \fBstrtoul\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.78 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。