When working with string streams and strings, how do you attain the same affect as the %02x format code from C?
I want to take a byte of data and store it as its hexidecimal equivilent in ASCII into either a string or string stream.
This is a discussion on C formatting codes in C++ within the C++ Programming forums, part of the General Programming Boards category; When working with string streams and strings, how do you attain the same affect as the %02x format code from ...
When working with string streams and strings, how do you attain the same affect as the %02x format code from C?
I want to take a byte of data and store it as its hexidecimal equivilent in ASCII into either a string or string stream.
You would use the std::hex manipulator for the hex output, std::setw(2) to set the field width to 2, and std::setfill('0') to set the fill character to '0'.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way