Convert string to long long integer
long long int atoll ( const char * str );
This function has the following parameter.
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.
If the converted value would be out of the range of representable values by a long long int, it causes undefined behavior.
#include <stdio.h> /* printf, fgets */
#include <stdlib.h> /* atoll */
/*from w w w . j ava2 s . c o m*/
int main (){
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);
return 0;
}
The code above generates the following result.