请问这段程序的结果是什么?
CString str="F2";
int i=atoi(str);
结果是什么?
[解决办法]
0
循环检测字符,遇到非数字的字符就退出,所以这个结果是0
[解决办法]
0
MSDN:
The return value is 0 (for atoi and _atoi64), 0L (for atol), or 0.0 (for atof) if the input cannot be converted to a value of that type.
最好的老师还是MSDN。。有困难先看看
[解决办法]
int i = 0;
str = "0xF2";
可以使用sscanf(str,"%d",&i);
这个可以得到正确的值,
LZ用的肯定是0,
[解决办法]
你怎么重复发贴..?
-----
atoi()解决不了你的问题..
CString str = "123";
int TheIntNum = atoi(str); //这是把数字字符串, 转化成对应的整数;
你的问题是把16进制数转化成10进制...