bwells Posted April 5, 2003 Posted April 5, 2003 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? Quote
Leaders Squirm Posted April 5, 2003 Leaders Posted April 5, 2003 Use itoa to convert from an int to a string buffer. The function takes a parameter which specifies which base to represent the number in. Pass it 16 for hexadecimal. Quote Search the forums | Still IRCing | Be nice
billy_bob169 Posted April 30, 2003 Posted April 30, 2003 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. Quote I'd rather be riding than working
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.