aboutsummaryrefslogblamecommitdiff
path: root/ja_JP.eucJP/man/man3/strtoul.3
blob: 3357ff7e78cfbecb4fbabba6e5411352315f5d49 (plain) (tree)



































                                                                              
                                                                                      
   
             



                



                                                                           




                                                         

                                                          










                                                         






                      













                                             


                                  





                  
                                 

                                                        
                      



                    
                         

        
                           





                                                                      
                                        




              
                   

          
                            










                              
                     







                          
                           


           
                                                                  




                                                                              










                                                                              
         
  
          
              
          
                  








                                    








                      

                            
.\" Copyright (c) 1990, 1991, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Chris Torek and the American National Standards Committee X3,
.\" on Information Processing Systems.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     @(#)strtoul.3	8.1 (Berkeley) 6/4/93
.\" %FreeBSD: src/lib/libc/stdlib/strtoul.3,v 1.3.2.5 2001/03/02 09:45:20 obrien Exp %
.\"
.\" $FreeBSD$
.Dd June 4, 1993
.Dt STRTOUL 3
.Os
.Sh 名称
.Nm strtoul , strtoull , strtouq
.Nd 文字列を unsigned long 値、unsigned long long 値または uquad_t 値に変換
.Sh ライブラリ
.Lb libc
.Sh 書式
.Fd #include <stdlib.h>
.Fd #include <limits.h>
.Ft unsigned long
.Fn strtoul "const char *nptr" "char **endptr" "int base"
.Ft unsigned long long
.Fn strtoull "const char *nptr" "char **endptr" "int base"
.Fd #include <sys/types.h>
.Fd #include <stdlib.h>
.Fd #include <limits.h>
.Ft u_quad_t
.Fn strtouq "const char *nptr" "char **endptr" "int base"
.Sh 解説
.Fn strtoul
関数は、
.Fa nptr
にある文字列を
.Em unsigned long
値に変換します。
.Fn strtoull
関数は、
.Fa nptr
にある文字列を
.Em unsigned long long
値に変換します。
.Fn strtouq
関数は、
.Fa nptr
にある文字列を
.Em u_quad_t
値に変換します。
変換は与えられた
.Fa base
に従って行われます。
この
.Fa base
の値は 2 から 36 の間か、
または特別な値である 0 でなければなりません。
.Pp
文字列は、任意の数の空白文字
.Xr (isspace 3
により決められるような) で始まり、
オプションで一つの
.Ql +
または
.Ql -
記号が続きます。
.Fa base
が 0 か 16 のとき、文字列は接頭辞
.Ql 0x
を含むことができ、数字は基数を 16 として読み取られます。
そうでないときの、0 の
.Fa base
では、その次の文字が
.Ql 0
でなければ
10 (10 進数) と見なされ、
.Ql 0
であれば
8 (8 進数) と見なされます。
.Pp
文字列の残りは、
与えられた基数では有効な数字ではない最初の文字のところで中止するという
わかりやすいやり方で
.Em unsigned long
値に変換されます。
(10 以上の基数では、大文字または小文字の
.Ql A
は 10 を、
.Ql B
は 11 を表し、
.Ql Z
は 35 を表します。)
.Pp
.Fa endptr
が空ポインタではない場合は、
.Fn strtoul
は最初の無効な文字のアドレスを
.Fa *endptr
に格納します。
数字が全くなかった場合は、
.Fn strtoul
は
.Fa nptr
の元の値を
.Fa *endptr
に格納します。
(従って、戻ったときに
.Fa *nptr
が
.Ql \e0
ではなく、
.Fa **endptr
が
.Ql \e0
である場合は、文字列全体が
有効だったことになります。)
.Sh 戻り値
.Fn strtoul
関数は、
元の (否定されていない) 値がオーバーフローを起こしそうにない限り、
変換の結果、もしくは先頭にマイナス記号がある場合には変換結果の否定を返します。
オーバーフローを起こす場合、
.Fn strtoul
は
.Dv ULONG_MAX
を返します。
.Fn strtoull
関数は、
元の (否定されていない) 値がオーバーフローを起こしそうにない限り、
変換の結果、もしくは先頭にマイナス記号がある場合には変換結果の否定を返します。
オーバーフローを起こす場合、
.Fn strtoull
は
.Dv ULLONG_MAX
を返します。
全ての場合で、
.Va errno
に
.Er ERANGE
を設定します。
.Sh エラー
.Bl -tag -width Er
.It Bq Er ERANGE
与えられた文字列が値域を超えました。
変換された値は固定されています。
.El
.Sh 参照
.Xr strtol 3
.Sh 規格
.Fn strtoul
関数は、
.St -isoC
に適合しています。
.Fn strtoll
関数は、
.St -isoC-99
に適合しています。
.Bx
.Fn strtoq
関数は推奨されません。
.Sh バグ
現在のロケールを無視します。