代码:
void CDemo1Dlg::OnOK() 
{
// TODO: Add extra validation here
UpdateData(TRUE);//获取数据A cstring strB;//获取数据B int nLen=m_ctlNumB.GetWindowTextLength();//获取字符串长度
if(nLen<=0)
{
AfxMessageBox(_T("请输入数字B!"));
return;
} m_ctlNumB.GetWindowText(strB);
int iB;
iB=atoi(strB); int n=m_iNumA+iB; Cstring strMsg;
strMsg.Format(_T("[%d]和[%d]的和为:[%d]!"),m_iNumA,iB,n);
AfxMessageBox(strMsg);
}错误报告:Compiling...
demo1Dlg.cpp
F:\[C++]\demo1\demo1Dlg.cpp(178) : error C2065: 'cstring' : undeclared identifier
F:\[C++]\demo1\demo1Dlg.cpp(178) : error C2146: syntax error : missing ';' before identifier 'strB'
F:\[C++]\demo1\demo1Dlg.cpp(178) : error C2065: 'strB' : undeclared identifier
F:\[C++]\demo1\demo1Dlg.cpp(193) : error C2065: 'Cstring' : undeclared identifier
F:\[C++]\demo1\demo1Dlg.cpp(193) : error C2146: syntax error : missing ';' before identifier 'strMsg'
F:\[C++]\demo1\demo1Dlg.cpp(193) : error C2065: 'strMsg' : undeclared identifier
F:\[C++]\demo1\demo1Dlg.cpp(194) : error C2228: left of '.Format' must have class/struct/union type
执行 cl.exe 时出错.demo1.exe - 1 error(s), 0 warning(s)