开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜