2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" References consulted:
|
|
|
|
.\" Linux libc source code
|
|
|
|
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
|
|
|
|
.\" 386BSD man pages
|
|
|
|
.\" Modified Mon Mar 29 22:39:41 1993, David Metcalfe
|
|
|
|
.\" Modified Sat Jul 24 21:38:42 1993, Rik Faith (faith@cs.unc.edu)
|
|
|
|
.\" Modified Sun Dec 17 18:35:06 2000, Joseph S. Myers
|
|
|
|
.\"
|
|
|
|
.TH ATOI 3 2000-12-17 "GNU" "Linux Programmer's Manual"
|
|
|
|
.SH NAME
|
|
|
|
atoi, atol, atoll, atoq \- convert a string to an integer
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <stdlib.h>
|
|
|
|
.sp
|
|
|
|
.BI "int atoi(const char *" nptr );
|
|
|
|
.br
|
|
|
|
.BI "long atol(const char *" nptr );
|
|
|
|
.br
|
|
|
|
.BI "long long atoll(const char *" nptr );
|
|
|
|
.br
|
|
|
|
.BI "long long atoq(const char *" nptr );
|
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2005-10-19 07:07:02 +00:00
|
|
|
The \fBatoi\fP() function converts the initial portion of the string
|
2004-11-03 13:51:07 +00:00
|
|
|
pointed to by \fInptr\fP to
|
|
|
|
.IR int .
|
|
|
|
The behaviour is the same as
|
|
|
|
.sp
|
|
|
|
.RS
|
|
|
|
.B strtol(nptr, (char **)NULL, 10);
|
|
|
|
.RE
|
|
|
|
.sp
|
2005-10-19 07:07:02 +00:00
|
|
|
except that \fBatoi\fP() does not detect errors.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2005-10-19 07:07:02 +00:00
|
|
|
The \fBatol\fP() and \fBatoll\fP() functions behave the same as
|
|
|
|
\fBatoi\fR(), except that they convert the initial portion of the
|
2004-11-03 13:51:07 +00:00
|
|
|
string to their return type of \fIlong\fP or \fIlong long\fP.
|
2005-10-19 07:07:02 +00:00
|
|
|
\fBatoq\fP() is an obsolete name for \fBatoll\fP().
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
|
|
|
The converted value.
|
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:30 +00:00
|
|
|
SVr4, POSIX.1-2001, 4.3BSD, C99.
|
|
|
|
C89 and
|
|
|
|
POSIX.1-1996 include the functions \fBatoi\fP() and \fBatol\fP() only.
|
|
|
|
.BR atoq (3)
|
|
|
|
is a GNU extension.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2005-10-19 07:07:02 +00:00
|
|
|
The non-standard \fBatoq\fP() function is not present in libc 4.6.27
|
2004-11-03 13:51:07 +00:00
|
|
|
or glibc 2, but is present in libc5 and libc 4.7 (though only as an
|
|
|
|
inline function in \fB<stdlib.h>\fP until libc 5.4.44). The
|
2005-10-19 07:07:02 +00:00
|
|
|
\fBatoll\fP() function is present in glibc 2 since version 2.0.2, but
|
2004-11-03 13:51:07 +00:00
|
|
|
not in libc4 or libc5.
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR atof (3),
|
|
|
|
.BR strtod (3),
|
|
|
|
.BR strtol (3),
|
|
|
|
.BR strtoul (3)
|