Originally Posted by
Lionmane
What I'm trying to do is take a hexidecimal integer of random size & convert it to the decimal equivalent.
Do you mean the text representation of an integer value? Can you use [s]printf?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
unsigned int hex = 0x63FDF0;
char *decimal = malloc(log10(hex) + 2);
if ( decimal )
{
sprintf(decimal, "%u", hex);
printf("hex = %X (%u), decimal = %s\n", hex, hex, decimal);
free(decimal);
}
return 0;
}
/* my output
hex = 63FDF0 (6553072), decimal = 6553072
*/