1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sun Jul 25 10:54:03 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Fixed typo, aeb, 950823
29 .\" 2002-02-22, joey, mihtjel: Added strtoull()
31 .\" Japanese Version Copyright (c) 1999 AKAMATSU, Kazuo
32 .\" and 2006 Akihiro MOTOKI
33 .\" all rights reserved.
34 .\" Translated Thu Jan 31 18:00:00 JST 1999
35 .\" by AKAMATSU, Kazuo
36 .\" Updated & Modified 2006-07-20,
37 .\" Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
41 .TH STRTOUL 3 2011-09-15 "GNU" "Linux Programmer's Manual"
43 .\"O strtoul, strtoull, strtouq \- convert a string to an unsigned long integer
44 strtoul, strtoull, strtouq \- 文字列を unsigned long int に変換する
47 .B #include <stdlib.h>
49 .BI "unsigned long int strtoul(const char *" nptr ", char **" endptr \
52 .BI "unsigned long long int strtoull(const char *" nptr ", char **" endptr ,
57 .\"O Feature Test Macro Requirements for glibc (see
58 .\"O .BR feature_test_macros (7)):
60 .RB ( feature_test_macros (7)
67 XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE ||
68 _POSIX_C_SOURCE\ >=\ 200112L;
77 .\"O function converts the initial part of the string
78 .\"O in \fInptr\fP to an
79 .\"O .I "unsigned long int"
80 .\"O value according to the
81 .\"O given \fIbase\fP, which must be between 2 and 36 inclusive, or be
82 .\"O the special value 0.
84 関数は、 \fInptr\fP の文字列の最初の部分を、
86 .I "unsigned long int"
88 この \fIbase\fP は 2 から 36 までの値
89 あるいは特別な意味を持つ値 0 でなければならない。
91 .\"O The string may begin with an arbitrary amount of white space (as
94 .\"O followed by a single optional \(aq+\(aq or \(aq\-\(aq
96 .\"O If \fIbase\fP is zero or 16, the string may then include a
97 .\"O "0x" prefix, and the number will be read in base 16; otherwise, a
98 .\"O zero \fIbase\fP is taken as 10 (decimal) unless the next character
99 .\"O is \(aq0\(aq, in which case it is taken as 8 (octal).
100 文字列の先頭には、任意の数の空白があってもよく (空白は
102 で判定される) 、また数字の直前には \(aq+\(aq か \(aq\-\(aq の
104 \fIbase\fP が 0 または 16 の場合には、 文字列の先頭に "0x" を置くことが
105 でき、その場合には文字列は 16進数として扱われる。
106 これ以外の文字列で \fIbase\fP が 0 の場合は、
107 文字列が \(aq0\(aq で始まるときは 8進数として、
108 それ以外のときは 10進数として扱われる。
110 .\"O The remainder of the string is converted to an
111 .\"O .I "unsigned long int"
112 .\"O value in the obvious manner,
113 .\"O stopping at the first character which is not a
114 .\"O valid digit in the given base.
115 .\"O (In bases above 10, the letter \(aqA\(aq in
116 .\"O either upper or lower case represents 10, \(aqB\(aq represents 11, and so
117 .\"O forth, with \(aqZ\(aq representing 35.)
119 .I "unsigned long int"
121 有効でない数字が現れた時点で変換は終了する。(11進数以上では \(aqA\(aq は
122 大文字・小文字に関わらず 10 を表し、 \(aqB\(aq は 11 を表現し,
123 以下同様に、 \(aqZ\(aq は 35 を表す。)
125 .\"O If \fIendptr\fP is not NULL,
127 .\"O stores the address of the
128 .\"O first invalid character in \fI*endptr\fP.
129 .\"O If there were no digits at
132 .\"O stores the original value of \fInptr\fP in
133 .\"O \fI*endptr\fP (and returns 0).
134 .\"O In particular, if \fI*nptr\fP is not \(aq\\0\(aq but \fI**endptr\fP
135 .\"O is \(aq\\0\(aq on return, the entire string is valid.
136 \fIendptr\fP がヌル値 (NULL) でない場合、
139 \fI*endptr\fP に格納している。
143 の元の値を \fI*endptr\fP に代入する(そして 0 を返す)。
144 特に、 \fI*nptr\fP が \(aq\\0\(aq 以外で、返された \fI**endptr\fP が
145 \(aq\\0\(aq ならば、文字列全体が有効だったことになる。
149 .\"O function works just like the
151 .\"O function but returns an
152 .\"O .I "unsigned long long int"
158 .I "unsigned long long int"
163 .\"O function returns either the result of the conversion
164 .\"O or, if there was a leading minus sign, the negation of the result of the
165 .\"O conversion represented as an unsigned value,
166 .\"O unless the original (nonnegated) value would overflow; in
167 .\"O the latter case,
171 .\"O and sets \fIerrno\fP to
174 関数は変換結果を返す。文字列がマイナス符号から始まっていた場
175 合は、(符号反転前の値がオーバーフローしていなければ) 変換結果を符号反転した
176 値を unsigned 型で返す。変換でオーバーフローが発生した場合は
183 .\"O Precisely the same holds for
188 .\"O .BR ULONG_MAX ).
203 .\"O contains an unsupported value.
210 .\"O The resulting value was out of range.
213 .\"O The implementation may also set \fIerrno\fP to \fBEINVAL\fP in case
214 .\"O no conversion was performed (no digits seen, and 0 returned).
215 実装によっては、全く変換が行われなかった場合(全く数字が現れず、
216 0 が返される)、\fIerrno\fP に \fBEINVAL\fP がセットされるかもしれない。
217 .\"O .SH "CONFORMING TO"
220 .\"O conforms to SVr4, C89, C99 and POSIX-2001, and
222 .\"O to C99 and POSIX.1-2001.
224 は SVr4, C89, C99 と POSIX-2001 に準拠している。
226 は C99 と POSIX.1-2001 に準拠している。
231 .\"O can legitimately return 0 or
233 .\"O .RB ( ULLONG_MAX
235 .\"O .BR strtoull ())
236 .\"O on both success and failure, the calling program should set
238 .\"O to 0 before the call,
239 .\"O and then determine if an error occurred by checking whether
241 .\"O has a nonzero value after the call.
253 が 0 以外の値かどうかを確認しエラーが発生したかどうかを判断する
256 .\"O In locales other than the "C" locale, other strings may be accepted.
257 "C" 以外のロケールの場合、その他の文字列も受け付けられるかもしれない。
258 .\"O (For example, the thousands separator of the current locale may be
260 (例えば、現在のロケールの 1000 毎の区切り文字に対応しているかもしれない。)
267 .BI "u_quad_t strtouq(const char *" nptr ", char **" endptr ", int " base );
271 .\"O with completely analogous definition.
273 .\"O Depending on the wordsize of the current architecture, this
274 .\"O may be equivalent to
278 使用中のアーキテクチャのワード長次第であるが、この関数は
284 .\"O Negative values are considered valid input and are
285 .\"O silently converted to the equivalent
286 .\"O .I "unsigned long int"
288 負の値も正当な入力とみなされ、エラーもなく、
290 .I "unsigned long int"
294 .\"O See the example on the
297 .\"O the use of the functions described in this manual page is similar.
300 このページで説明した関数の使用方法も同様である。