A width specifier is not going to do it, because it can only be used to pad, not to truncate, the char gets promoted to an int when you pass it to a function, and printf expects an unsigned int for %x.
pgnatyuk showed one way to fix it. Here's another:
printf("m = %x \n", m & 0xFF);
This works because it masks out the leading FFs you get from sign extension.
Main Topics
Browse All Topics





by: pgnatyukPosted on 2009-09-22 at 23:17:52ID: 25400418
Like that?
Select allOpen in new window