outputing hexidecimal using cout

  • Thread starter daniel aviad galron
  • Start date
D

daniel aviad galron

Greetings. I need to output a hexadecimal number using cout. I've done
this as shown below:
cout << hex << stuff;
But it outputs the letters in lowercase. Is it possible to output
a,b,c,d,e, and f in upper case instead of lower case?

Thanks

-D
 
J

Josh Sebastian

Greetings. I need to output a hexadecimal number using cout. I've done
this as shown below:
cout << hex << stuff;
But it outputs the letters in lowercase. Is it possible to output
a,b,c,d,e, and f in upper case instead of lower case?

Did you try

cout << hex << uppercase << stuff;

?
 
M

Mike Wahler

daniel aviad galron said:
Greetings. I need to output a hexadecimal number using cout. I've done
this as shown below:
cout << hex << stuff;
But it outputs the letters in lowercase. Is it possible to output
a,b,c,d,e, and f in upper case instead of lower case?

Yes. Your needs have been anticipated and provided
via another handy-dandy stream manipulator:

#include <iomanip>
#include <iostream>

int main()
{
std::cout << std::hex << std::uppercase << 0x3d << '\n';
return 0;
}

-Mike
 
M

Mike Wahler

Mike Wahler said:
Yes. Your needs have been anticipated and provided
via another handy-dandy stream manipulator:

#include <iomanip>

Should be:

#include <ios>

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top