By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,951 Members | 1,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,951 IT Pros & Developers. It's quick & easy.

IO Manipulator: Partial 'uppercase'?

P: n/a
When outputting an integer as hexadecimal, is it possible to set the
stream so that the basefield is lowercase, but the values are uppercase?
For example:
#include <iostream>

int main()
{
using std::cout;
using std::hex;
using std::showbase;
using std::uppercase;

int i = 42;
cout << i << '\n';
cout << hex << showbase << i << '\n';
cout << uppercase << i << '\n';
}
The output is:
42
0x2a
0X2A
However, I would like to have the output format be like:
0x2A

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Marcus Kwok wrote:
When outputting an integer as hexadecimal, is it possible to set the
stream so that the basefield is lowercase, but the values are
uppercase? For example:
#include <iostream>

int main()
{
using std::cout;
using std::hex;
using std::showbase;
using std::uppercase;

int i = 42;
cout << i << '\n';
cout << hex << showbase << i << '\n';
cout << uppercase << i << '\n';
}
The output is:
42
0x2a
0X2A
However, I would like to have the output format be like:
0x2A
Remove showbase and output "0x" yourself.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 23 '07 #2

P: n/a
Victor Bazarov <v.********@comacast.netwrote:
Marcus Kwok wrote:
>When outputting an integer as hexadecimal, is it possible to set the
stream so that the basefield is lowercase, but the values are
uppercase? For example:
[snip]
>>
However, I would like to have the output format be like:
0x2A

Remove showbase and output "0x" yourself.
OK, thanks.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.