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 strtoul, strtoull, strtouq \- 文字列を unsigned long int に変換する
46 .B #include <stdlib.h>
48 .BI "unsigned long int strtoul(const char *" nptr ", char **" endptr \
51 .BI "unsigned long long int strtoull(const char *" nptr ", char **" endptr ,
57 .RB ( feature_test_macros (7)
64 XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE ||
65 _POSIX_C_SOURCE\ >=\ 200112L;
73 関数は、 \fInptr\fP の文字列の最初の部分を、
75 .I "unsigned long int"
77 この \fIbase\fP は 2 から 36 までの値
78 あるいは特別な意味を持つ値 0 でなければならない。
80 文字列の先頭には、任意の数の空白があってもよく (空白は
82 で判定される) 、また数字の直前には \(aq+\(aq か \(aq\-\(aq の
84 \fIbase\fP が 0 または 16 の場合には、 文字列の先頭に "0x" を置くことが
85 でき、その場合には文字列は 16進数として扱われる。
86 これ以外の文字列で \fIbase\fP が 0 の場合は、
87 文字列が \(aq0\(aq で始まるときは 8進数として、
91 .I "unsigned long int"
93 有効でない数字が現れた時点で変換は終了する。(11進数以上では \(aqA\(aq は
94 大文字・小文字に関わらず 10 を表し、 \(aqB\(aq は 11 を表現し,
95 以下同様に、 \(aqZ\(aq は 35 を表す。)
97 \fIendptr\fP がヌル値 (NULL) でない場合、
100 \fI*endptr\fP に格納している。
104 の元の値を \fI*endptr\fP に代入する(そして 0 を返す)。
105 特に、 \fI*nptr\fP が \(aq\\0\(aq 以外で、返された \fI**endptr\fP が
106 \(aq\\0\(aq ならば、文字列全体が有効だったことになる。
112 .I "unsigned long long int"
116 関数は変換結果を返す。文字列がマイナス符号から始まっていた場
117 合は、(符号反転前の値がオーバーフローしていなければ) 変換結果を符号反転した
118 値を unsigned 型で返す。変換でオーバーフローが発生した場合は
144 実装によっては、全く変換が行われなかった場合(全く数字が現れず、
145 0 が返される)、\fIerrno\fP に \fBEINVAL\fP がセットされるかもしれない。
148 は SVr4, C89, C99 と POSIX-2001 に準拠している。
150 は C99 と POSIX.1-2001 に準拠している。
163 が 0 以外の値かどうかを確認しエラーが発生したかどうかを判断する
166 "C" 以外のロケールの場合、その他の文字列も受け付けられるかもしれない。
167 (例えば、現在のロケールの 1000 毎の区切り文字に対応しているかもしれない。)
173 .BI "u_quad_t strtouq(const char *" nptr ", char **" endptr ", int " base );
178 使用中のアーキテクチャのワード長次第であるが、この関数は
184 負の値も正当な入力とみなされ、エラーもなく、
186 .I "unsigned long int"
191 このページで説明した関数の使用方法も同様である。