This is a code that gets some info about network the problem is when it prints the MAC address it prints it sometime normally and sometime with fff\'s like 00:21:84:a2:12:88
I prefer use an explicit length modifier in format string for values shorter than int. For example %02hhx
instead of %02x
for one-byte values. It allow me to not worry about those subtle conversion and promotion issues:
#include
int main(void)
{
signed char sff = '\xff';
unsigned char uff = '\xff';
printf("signed: %02x %02hhx\n", sff, sff);
printf("unsigned: %02x %02hhx\n", uff, uff);
return 0;
}
prints
signed: ffffffff ff
unsigned: ff ff