void Cwork::OnChangeshoujia()
{
UpdateData();
float nVal1, nVal2, nVal3;
nVal1 = atoi(m_shoujia);
nVal2 = atoi(m_chengben);
nVal3 = nVal1 - nVal2;
m_maoli.Format("%d", nVal3);
UpdateData(false);
}
我想让它可以计算小数,但是这个atoi是转换的int型吧?
有转换成float或者double的么?
我基础比较差,,能不能多告诉我一些类似atoi的类型转换的函数?
{
UpdateData();
float nVal1, nVal2, nVal3;
nVal1 = atoi(m_shoujia);
nVal2 = atoi(m_chengben);
nVal3 = nVal1 - nVal2;
m_maoli.Format("%d", nVal3);
UpdateData(false);
}
我想让它可以计算小数,但是这个atoi是转换的int型吧?
有转换成float或者double的么?
我基础比较差,,能不能多告诉我一些类似atoi的类型转换的函数?
Format("%.2f")转换
还是一点,为什么不直接定义数值型变量呢??????
double atof(
const char *str
);
double _wtof(
const wchar_t *str
);
MSDN上面都有说明
const char *str
);
double _wtof(
const wchar_t *str
);int atoi(
const char *str
);
int _wtoi(
const wchar_t *str
);
int _atoi_l(
const char *str,
_locale_t locale
);
int _wtoi_l(
const wchar_t *str,
_locale_t locale
);long atol(
const char *str
);
long _atol_l(
const char *str,
_locale_t locale
);
long _wtol(
const wchar_t *str
);
long _wtol_l(
const wchar_t *str,
_locale_t locale
);