 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
David Rubin Guest
|
Posted: Thu Oct 30, 2003 5:16 pm Post subject: printing hex values |
|
|
This is totally lame...How do I use iomanip's to get the equivalent of
printf("%#.8x", 0xabcd);
which should yield
0x0000abcd
I tried
std::cout << std::setprecision( << std::hex << std::showbase <<
0xabcd;
to no avail.
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Thu Oct 30, 2003 6:12 pm Post subject: Re: printing hex values |
|
|
"David Rubin" <bogus_address (AT) nomail (DOT) com> wrote
| Quote: | This is totally lame...How do I use iomanip's to get the equivalent of
printf("%#.8x", 0xabcd);
which should yield
0x0000abcd
I tried
std::cout << std::setprecision( << std::hex << std::showbase
0xabcd;
|
#include
#include <iomanip>
#include <iostream>
int main()
{
std::cout << std::hex << std::showbase
<< std::setw(10) << std::setfill('0')
<< std::internal
<< 0xabcd << 'n';
return 0;
}
HTH,
-Mike
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|