Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have an integer value and I want to convert the value to a hex number. I think I can use the cin >> operator but I am not sure of the syntax. Can someone tell me an easy way to do this conversion?
  • 4 weeks later...
Posted

Don't Know if it is still of use to you, but try this if it is:

 

int main()

{

cout.unsetf(ios::dec);

cout.setf(ios::hex);

 

cout << 100;

 

cin.get();

return 0;

}

 

This changes how cout looks at integers. You can also develop formatted i/o using many other format flags. You should really check it out. While you are at it, you should check out i/o manipulators...they make the code a lot more user friendly.

I'd rather be riding than working

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...