1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the American National Standards Committee X3, on Information 6.\" Processing Systems. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)atol.3 8.1 (Berkeley) 6/4/93 33.\" $FreeBSD: src/lib/libc/stdlib/atol.3,v 1.14 2007/01/09 00:28:09 imp Exp $ 34.\" 35.Dd November 17, 2013 36.Dt ATOL 3 37.Os 38.Sh NAME 39.Nm atol , 40.Nm atoll , 41.Nm atol_l , 42.Nm atoll_l 43.Nd convert 44.Tn ASCII 45string to 46.Vt long 47or 48.Vt "long long" 49integer 50.Sh LIBRARY 51.Lb libc 52.Sh SYNOPSIS 53.In stdlib.h 54.Ft long 55.Fn atol "const char *nptr" 56.Ft "long long" 57.Fn atoll "const char *nptr" 58.In xlocale.h 59.Ft long 60.Fn atol_l "const char *nptr" "locale_t loc" 61.Ft "long long" 62.Fn atoll_l "const char *nptr" "locale_t loc" 63.Sh DESCRIPTION 64The 65.Fn atol 66function converts the initial portion of the string pointed to by 67.Fa nptr 68to 69.Vt long 70integer 71representation. 72.Pp 73It is equivalent to: 74.Pp 75.Dl "strtol(nptr, NULL, 10);" 76.Pp 77The 78.Fn atoll 79function converts the initial portion of the string pointed to by 80.Fa nptr 81to 82.Vt "long long" 83integer 84representation. 85.Pp 86It is equivalent to: 87.Pp 88.Dl "strtoll(nptr, NULL, 10);" 89.Pp 90The _l-suffixed versions take an explicit locale argument, whereas the 91non-suffixed versions use the current global or per-thread locale. 92.Sh ERRORS 93The functions 94.Fn atol 95and 96.Fn atoll 97need not 98affect the value of 99.Va errno 100on an error. 101.Sh SEE ALSO 102.Xr atof 3 , 103.Xr atoi 3 , 104.Xr strtod 3 , 105.Xr strtol 3 , 106.Xr strtoul 3 , 107.Xr xlocale 3 108.Sh STANDARDS 109The 110.Fn atol 111function 112conforms to 113.St -isoC . 114The 115.Fn atoll 116function 117conforms to 118.St -isoC-99 . 119