我用MFC做了一个编辑框加法运算程序,加按钮代码如下:
void CZhhDlg::OnAddButton() 
{
char cstrItem1[10],cstrItem2[10];
double dfItem1,dfItem2,dfResult;
char cBuffer[50];;
m_Item1_Edit.GetWindowText(cstrItem1,10);
         m_Item2_Edit.GetWindowText(cstrItem2,10);
dfItem1=atof((LPCTSTR)cstrItem1);
         dfItem2=atof((LPCTSTR)cstrItem2);
dfResult=dfItem1+dfItem2;
_gcvt(dfResult,10,cBuffer);
m_sResult_Edit=(LPCTSTR)cBuffer;
UpdateData(FALSE);
}
这个程序现在好用,但我想把符点数变成只计算整型数据,我将double变为int
,将atof变为atoi,程序检验未出错,但并不能实现变为整数加法的功能,请指教!