KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know how to cause it to be in hex: unsigned char myNum = 0xA7; clog << "Output: " std::hex << int(myNum) << endl; // Gives: // Output: A7 Now I want it to always print a leading zero if myNum only requires one digit: unsigned char myNum = 0x8; // Pretend std::hex takes an argument to specify number of digits. clog << "Output: " << std::hex(2) << int(myNum) << endl; // Desired: // Output: 08 So how can I actually do this?
Tags (comma-separated)
Save Edits
Cancel