#include <stdio.h>
int _htoi(char *h)
{
int ret;
ret = 0;
for (; *h; h++)
ret = ret*16 + *h-(*h>='0'&&*h<='9' ? '0' : (*h>='A'&&*h<='F' ? '7' : 'W'));
return ret;
}
char *_itoh(char *buf, int bufsize, int n)
{
char *hex="0123456789ABCDEF";
int i=bufsize-1;
buf[i] = 0;
for (--i; n; n/=16,i--)
buf[i] = hex[n%16];
return buf+i+1;
}
main()
{
char buf[256];
printf("%s\n", _itoh(buf, 256, 123456789));
printf("%d\n", _htoi(_itoh(buf, 256, 123456789)));
printf("%d\n", _htoi("75bcd15"));
}