Format HEX string...


what best way format hex string this:

ff08dc0a00

the array setup this:
static uint8_t test[] = { 0xff, 0x08, 0xdc, 0x00, 0x0a, 0x00 };

but doing following:
sprintf(tmpbuf, "%x%x%x%x", test[0], test[1], test[2], test[3]);

returns following:
ff8dca0

basically removing leading "0".

use %02x format specifier instead of %x:

code: [select]
sprintf(tmpbuf, "%02x%02x%02x%02x", test[0], test[1], test[2], test[3]);

--
the quick shield: breakout 28 pins quick-connect terminals


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Format HEX string...


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums