2006/10/02

dectohex

decToHex-funktio C:llä

const char *dec_to_hex(unsigned long dec)
{
static char buf[9];
for(int i=7;i>=0;i--)
buf[(7-i)]=((dec>>i*4)&0xF)["0123456789ABCDEF"];
buf[8] = 0;
return buf;
}

Kommentteja?

Ei kommentteja: