Convert string to long long integer
long long int strtoll (const char* str, char** endptr, int base);
This function has the following parameter.
returns the converted integral number as a long int value.
If no valid conversion could be performed, a zero value is returned ( 0LL).
#include <stdio.h> /* printf, NULL */
#include <stdlib.h> /* strtoll */
/* www. j a v a 2 s. co m*/
int main (){
char szNumbers[] = "1231231235 17b00a12b -01100011010110 0x6fffff";
char* pEnd;
long long int lli1, lli2, lli3, lli4;
lli1 = strtoll (szNumbers, &pEnd, 10);
lli2 = strtoll (pEnd, &pEnd, 16);
lli3 = strtoll (pEnd, &pEnd, 2);
lli4 = strtoll (pEnd, NULL, 0);
printf ("The decimal equivalents are: %lld, %lld, %lld and %lld.\n", lli1, lli2, lli3, lli4);
return 0;
}
The code above generates the following result.