1. Home
  2. Computing & Technology
  3. Linux
Linux / Unix Command: atol
Command Library

NAME

atoi, atol, atoll, atoq - convert a string to an integer.  

SYNOPSIS

#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);
 

DESCRIPTION

The atoi() function converts the initial portion of the string pointed to by nptr to int. The behaviour is the same as

strtol(nptr, (char **)NULL, 10);

except that atoi() does not detect errors.

The atol() and atoll() functions behave the same as atoi(), except that they convert the initial portion of the string to their return type of long or long long. atoq() is an obsolete name for atoll().  

RETURN VALUE

The converted value.  

CONFORMING TO

SVID 3, POSIX.1, BSD 4.3, ISO/IEC 9899. ISO/IEC 9899:1990 (C89) and POSIX.1 (1996 edition) include the functions atoi() and atol() only; C99 adds the function atoll().  

SEE ALSO

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


Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux/Unix Command Library

>> Shell Command Library

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.