In article <VP******************@twister.austin.rr.com>,
cp***@austin.rr.com says...
Can someone give me an example of how to use the hex manipulator defined in
<iomanip>. I am reading the doc but it doesnt give me the syntax, or at
least I don't understand it.
#include <iostream>
#include <iomanip>
int main() {
std::cout << std::hex << 12345;
return 0;
}
Note that there are two entirely different things named "hex" -- the one
I used above is a manipulator. The other (std::ios::hex) is a constant
value that will set a base to hexadecimal when it's passed to
setiosflags -- if you accidentally print it out, you'll get some value
(normally a power of two) preceding your own value, which will still be
printed in decimal. E.g. the output from the program above should be
"3039", which is 12345 converted to hexadecimal. OTOH, code like this:
std::cout << std::ios::hex << 12345;
will typically produce output something like "1612345" or "204812345".
--
Later,
Jerry.
The universe is a figment of its own imagination.