atoll - C stdlib.h

C examples for stdlib.h:atoll

Type

function

From


<cstdlib>
<stdlib.h>

Description

Convert string to long long integer

Prototype

long long int atoll ( const char * str );

Parameters

Parameter Description
str C-string 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 made, a zero value is returned.

Demo Code


#include <stdio.h> /* printf, fgets */
#include <stdlib.h> /* atoll */

int main ()//from  ww  w.j a v a 2 s. c o  m
{
  long long int lli;
  char buffer[256];
  printf ("Enter a long number: ");
  fgets (buffer, 256, stdin);
  lli = atoll(buffer);
  printf ("The value entered is %lld. Its double is %lld.\n",lli,lli*2);

  printf ("%lld.\n", atoll("123123123"));
  printf ("%lld.\n", atoll("a"));
  return 0;
}

Related Tutorials