function

atoll

<cstdlib>
long long int atoll ( const char * str );
Convert string to long long integer
Parses the C string str interpreting its content as an integral number, which is returned as a long long int value.

This function operates like atol to interpret the string, but produces numbers of type long long int (see atol for details on the interpretation process).

Parameters

str
C string containing the representation of an integral number.

Return Value

On success, the function returns the converted integral number as a long long int value.
If no valid conversion could be performed, a zero value is returned.
There is no standard specification on what happens when the converted value would be out of the range of representable values by a long long int. See strtoll for a more robust cross-platform alternative when this is a possibility.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* atoll example */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  long int li;
  char szInput [256];
  printf ("Enter a long number: ");
  gets ( szInput );
  li = atoll (szInput);
  printf ("The value entered is %d. The double is %d.\n",li,li*2);
  return 0;
}


Output:

Enter a number: 9275806
The value entered is 9275806. The double is 18551612.

See also