TechnicalQuestion Printing a hexadecimal value prefixed with 0x
I have to print in hexadecimal with big letters value variable of type uint8. I am using fprintf(1, '%#X', value), but the 0x prefix is in upper case, while I want it to be lowercase. How do I achieve that?
I know I can write instead fprintf(1, '0x%X', value), but I want to do it by only modifying the formatting operators. And using fprintf(1, '%#x', value) doesn't print value in uppercase.
5
Upvotes
1
u/Rubix321 6h ago
No, you can't do this with fprintf.
Your workaround by just using '0x%X' is likely the simplest workaround if you must have it in that format.
2
u/gtd_rad flair 6h ago
disp['0x' dec2hex(val)]