在Unicode字符集下,使用_ttoi()和_ttof()函数:
例:CString str = _T(“23”);
float f_value = _ttof(str);
int i_value = _ttoi(str);
在非Unicode字符集下,使用atoi()和atof()函数:
例:CString str = _T(“23”);
float f_value = atof(str);
int i_value = atoi(str);
注:输入str的范围不要超出int或float类型的范围。
每次用到转换时都要查找,借此机会做个总结,方便自己使用,也方便与大家交流。