Convert string to unsigned long long integer
unsigned long long int strtoull (const char* str,
char** endptr,
int base);
This function has the following parameter.
returns the converted integral number as an unsigned long long int value.
If no valid conversion could be performed, a zero value is returned ( 0ULL).
#include <stdio.h> /* printf, NULL */
#include <stdlib.h> /* strtoull */
//from www . j a va 2s . c o m
int main (){
char szNumbers[] = "250 76af00 110001101111010 0x6fffff";
char * pEnd;
unsigned long long int ulli1, ulli2, ulli3, ulli4;
ulli1 = strtoull (szNumbers, &pEnd, 10);
ulli2 = strtoull (pEnd, &pEnd, 16);
ulli3 = strtoull (pEnd, &pEnd, 2);
ulli4 = strtoull (pEnd, NULL, 0);
printf ("The decimal equivalents are: %llu, %llu, %llu and %llu.\n", ulli1, ulli2, ulli3, ulli4);
return 0;
}
The code above generates the following result.