atoi

Autres langues

Langue: ja

Version: 17 December 2000 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

名前

atoi, atol, atoll, atoq - 文字列を整数型に変換する

書式

 #include <stdlib.h>
 
 int atoi(const char *nptr);
 
long atol(const char *nptr);
long long atoll(const char *nptr);
long long atoq(const char *nptr);

説明

atoi() 関数は、nptr によって指示される文字列のはじめの部分を int 型整数に変換する。 この振る舞いは、 atoi() 関数がエラーを見つけない点以外は、
strtol(nptr, (char **) NULL, 10);

と同じである。

atol() 関数と atoll() 関数は atoi() と同様の振る舞いをするが、 文字列のはじめの部分をそれぞれ longlong long に変換する。 atoq() は atoll() の古い名前である。

返り値

変換された値。

準拠

SVr4, POSIX.1-2001, 4.3BSD, C99. C89 と POSIX.1-1996 には atoi() と atol() だけが含まれている。 atoq(3) は GNU による拡張である。

注意

非標準である atoq() 関数は libc 4.6.27 や glibc 2 には含まれていないが、 libc5 と libc 4.7 には存在している (ただし libc 5.4.44 までは <stdlib.h> のインライン関数のみである)。 atoll() 関数は glibc 2 のバージョン 2.0.2 から存在しているが、 libc4 や libc5 には存在しない。

関連項目

atof(3), strtod(3), strtol(3), strtoul(3)