std::atoi, std::atol, std::atoll

From Cppreference

Jump to: navigation, search
Defined in header <cstdlib>

int       atoi( const char *str );

long      atol( const char *str )

long long atoll( const char *str );
(C++11 feature)

Interprets an integer value in a character string pointed to by str.

Function discards any whitespace characters until first non-whitespace character is found. Then it takes as many characters as possible to form a valid integer number representation and converts them to integer value. The valid integer value consists of the following parts:

Contents

[edit] Parameters

str - pointer to the null-terminated character string to be interpreted

[edit] Return value

integer value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, INT_MAX, INT_MIN, LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, 0 is returned.

[edit] Example

[edit] See also

strtol
strtoll
converts a character string to an integer value
(function)
strtoul
strtoull
converts a character string to an unsigned integer value
(function)