% llu should work as it has been added to the standard. however, you can use the secure version of snprintf or consider writing your own function better than snprintf. You may be interested here.
char *ulltostr(uint64 value, char *ptr, int base)
{
uint64 t = 0, res = 0;
uint64 tmp = value;
int count = 0;
if (NULL == ptr)
{
return NULL;
}
if (tmp == 0)
{
count++;
}
while(tmp > 0)
{
tmp = tmp/base;
count++;
}
ptr += count;
*ptr = '\0';
do
{
res = value - base * (t = value / base);
if (res < 10)
{
* --ptr = '0' + res;
}
else if ((res >= 10) && (res < 16))
{
* -- ptr = 'A' - 10 + res;
}
} while ((value = t) != 0);
return(ptr);
}
source
share