如何将CString中的十六进制值转换为十进制值? [英] How to convert Hexadecimal value in CString to Decimal value?
本文介绍了如何将CString中的十六进制值转换为十进制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将CString中的十六进制值转换为十进制值?
How to convert Hexadecimal value in CString to Decimal value?
推荐答案
您可以使用 ^ ]函数.将十六进制指定为16.
you can use the strtol[^] function. Specify the base as 16 for hex.
CString myString = "FA"; //0xFA = 250
long myNumber = strtol((LPCSTR)myString, NULL, 16); //We dont care where the end of the string was for this example, so the 2nd param is NULL
//myNumber = 250;
长num = strtol(((LPCSTR)myString,NULL,16);
CString rev;
rev.Format(_T(%d"),num);
现在Cstring版本中有值1291.
long num = strtol((LPCSTR)myString, NULL, 16);
CString rev;
rev.Format(_T("%d"),num);
Now the value 1291 is there in the Cstring rev.
这篇关于如何将CString中的十六进制值转换为十进制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文