C examples for stdlib.h:atoll
function
<cstdlib> <stdlib.h>
Convert string to long long integer
long long int atoll ( const char * str );
Parameter | Description |
---|---|
str | C-string representation of an integral number. |
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.
#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; }