#include <stdio.h>
#include <string.h>
#include <stdint.h>
typedef unsigned int uint32_t ;
typedef unsigned short uint16_t ;
typedef unsigned char uint8_t ;
unsigned char str_to_hex(unsigned char data)
{
if(data <= '9')
{
return data-'0';
}
else if((data >= 'A')&&(data <= 'F'))
{
return data+10-'A';
}
else
{
return data+10-'a';
}
}
uint64_t atol64( char *str)//#include <stdint.h> uint64_t
{
uint64_t t[16]={0};
uint8_t i=0 , cnt =0 , j =0;
uint64_t temp = 0;
while( *str != '\0')
{
t[cnt++] = str_to_hex(*str);
str++;
if( cnt > 16)
{
return 0;
}
}
j = cnt -1;
for( i = 0 ; i < cnt ; i++)
{
temp |= t[j--]<<(i*4);
}
return temp;
}
const char *id = "045897db00000000";
int main(void)
{
uint64_t ID = atol64((char*)id);
printf("%s--%llx\n",id,ID );//045897db00000000--45897db00000000
return 1;
}