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".
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:
--
the quick shield: breakout 28 pins quick-connect terminals
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
Post a Comment