]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
4b72fb64 | 3 | .\" %%%LICENSE_START(verbatim) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified Mon Mar 29 22:39:41 1993, David Metcalfe | |
30 | .\" Modified Sat Jul 24 21:38:42 1993, Rik Faith (faith@cs.unc.edu) | |
31 | .\" Modified Sun Dec 17 18:35:06 2000, Joseph S. Myers | |
32 | .\" | |
13f78d96 | 33 | .TH ATOI 3 2012-08-03 "GNU" "Linux Programmer's Manual" |
fea681da MK |
34 | .SH NAME |
35 | atoi, atol, atoll, atoq \- convert a string to an integer | |
36 | .SH SYNOPSIS | |
37 | .nf | |
38 | .B #include <stdlib.h> | |
39 | .sp | |
40 | .BI "int atoi(const char *" nptr ); | |
41 | .br | |
42 | .BI "long atol(const char *" nptr ); | |
43 | .br | |
44 | .BI "long long atoll(const char *" nptr ); | |
45 | .br | |
46 | .BI "long long atoq(const char *" nptr ); | |
47 | .fi | |
cc4615cc MK |
48 | .sp |
49 | .in -4n | |
50 | Feature Test Macro Requirements for glibc (see | |
51 | .BR feature_test_macros (7)): | |
52 | .in | |
53 | .sp | |
54 | .ad l | |
55 | .BR atoll (): | |
e0a98111 | 56 | .RS 4 |
6c3f0228 MK |
57 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || |
58 | _POSIX_C_SOURCE\ >=\ 200112L; | |
e0a98111 MK |
59 | .br |
60 | or | |
cc4615cc | 61 | .I cc\ -std=c99 |
e0a98111 MK |
62 | .RE |
63 | .ad | |
fea681da | 64 | .SH DESCRIPTION |
60a90ecd MK |
65 | The |
66 | .BR atoi () | |
67 | function converts the initial portion of the string | |
fea681da MK |
68 | pointed to by \fInptr\fP to |
69 | .IR int . | |
d9bfdb9c | 70 | The behavior is the same as |
fea681da | 71 | .sp |
2147452b | 72 | .in +4n |
13f78d96 | 73 | strtol(nptr, NULL, 10); |
2147452b | 74 | .in |
fea681da | 75 | .sp |
60a90ecd MK |
76 | except that |
77 | .BR atoi () | |
78 | does not detect errors. | |
fea681da | 79 | .PP |
60a90ecd MK |
80 | The |
81 | .BR atol () | |
82 | and | |
83 | .BR atoll () | |
84 | functions behave the same as | |
85 | .BR atoi (), | |
86 | except that they convert the initial portion of the | |
fea681da | 87 | string to their return type of \fIlong\fP or \fIlong long\fP. |
60a90ecd MK |
88 | .BR atoq () |
89 | is an obsolete name for | |
90 | .BR atoll (). | |
47297adb | 91 | .SH RETURN VALUE |
fea681da | 92 | The converted value. |
47297adb | 93 | .SH CONFORMING TO |
c13182ef | 94 | SVr4, POSIX.1-2001, 4.3BSD, C99. |
68e1685c | 95 | C89 and |
60a90ecd MK |
96 | POSIX.1-1996 include the functions |
97 | .BR atoi () | |
98 | and | |
99 | .BR atol () | |
100 | only. | |
2777b1ca | 101 | .BR atoq () |
68e1685c | 102 | is a GNU extension. |
fea681da | 103 | .SH NOTES |
c8f2dd47 | 104 | The nonstandard |
60a90ecd MK |
105 | .BR atoq () |
106 | function is not present in libc 4.6.27 | |
fea681da | 107 | or glibc 2, but is present in libc5 and libc 4.7 (though only as an |
c84371c6 | 108 | inline function in \fI<stdlib.h>\fP until libc 5.4.44). |
60a90ecd MK |
109 | The |
110 | .BR atoll () | |
111 | function is present in glibc 2 since version 2.0.2, but | |
fea681da | 112 | not in libc4 or libc5. |
47297adb | 113 | .SH SEE ALSO |
fea681da MK |
114 | .BR atof (3), |
115 | .BR strtod (3), | |
116 | .BR strtol (3), | |
117 | .BR strtoul (3) |