Program to Convert decimal to hexadecimal in VC++?
How to convert decimal to hexadecimal in VC++(MFC A开发者_运维知识库pplication) ? THANKS.
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/
MFC you say?
CString bla;
int yournumber = 15;
bla.Format("%x", yournumber );
If you mean converting an int into a hex string, this would be a C++ solution:
int num = value;
string numHexStr;
stringstream ss;
ss << hex << num;
ss >> numHexStr;
You can add the uppercase manipulator for, well, uppercase. e.g.
ss << uppercase << hex << num;
If you want something more Cish you can use sprintf with %x or %X to get lower or upper case accordingly. e.g.
sprintf(str, "%x", num);
精彩评论