KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to output the hex value of a char and format it in a nice way. Required: 0x01 : value 0x1 All I can get is: 00x1 : value 0x1 // or 0x1 if i don't use iomanip Here's the code i have, 'ch' was declared to be a unsigned char. Is there any other way to do it other than checking the value and manually add an '0'?? cout << showbase; cout << hex << setw(2) << setfill('0') << (int) ch; Edit: I found one solution online: cout << internal << setw(4) << setfill('0') << hex << (int) ch
Tags (comma-separated)
Save Edits
Cancel