Use C atoll function to convert string to long long type
Syntax
C atoll function has the following format.
long long int atoll(const char *str);
Header
C atoll function is
from header file stdlib.h
.
Description
C atoll function
converts the string pointed to by str into a long
long int value. It is otherwise similar to atol()
.
Example
C atoll function converts string to long long type.
#include <stdlib.h>
#include <stdio.h>
/*from w w w. j av a 2 s .c o m*/
int main(void)
{
char num1[80], num2[80];
printf("Enter first: ");
gets(num1);
printf("Enter second: ");
gets(num2);
printf("The sum is: %ld.", atoll(num1)+atoll(num2));
return 0;
}
The code above generates the following result.