首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC实现编辑框写功能程序异常

2012-03-29 
【求助】MFC实现编辑框写功能程序错误MFC实现编辑框写功能,程序如下:void CTest08Dlg::OnBtnWriteFile() {//

【求助】MFC实现编辑框写功能程序错误

MFC实现编辑框写功能,程序如下:
void CTest08Dlg::OnBtnWriteFile()
{
// TODO: Add your control notification handler code here
CFileDialogFiledlg(FALSE,"All file","*.*",OFN_HIDEREADONLY,"All File(*.*)");

Filedlg.m_ofn.lpstrTitle="写文件";
CStringm_strFileName;
CStringm_strFileExm;
CStringM_strFileData;
CFilecFile;
CFileExceptione;
unsigned longlSize;

if (Filedlg.DoModal()!=IDOK)
{
return;
}
else
{
m_strFileName=Filedlg.GetPathName();
m_strFileExm=Filedlg.GetFileExt();

if (cFile.Open(m_strFileName,CFile::modeCreate|CFile::modeWrite,&e))
{
m_ctrFileData.GetWindowText(M_strFileData);
lSize=M_strFileData.GetLength();
char*pBuf=new char[lSize+1];
if (!pBuf)
{
cFile.Close();
return;
}
else
{
strcpy(pBuf,(char*)(LPCSTR)M_strFileData);
*(pBuf+lSize)='\0';
cFile.WriteHuge(pBuf,lSize);
m_ctrFileData.SetWindowText(pBuf);
if (pBuf)
{
DELETE[]pBuf;//错误行!!!!!!!!!!!!
}
cFile.Close();
}
}
else
{
TCHARszCause[255];
CStringstrFormattted;
e.GetErrorMessage(szCause,255);
strFormattted=_T("The data file could not be read because of this error:");
strFormattted+=szCause;
AfxMessageBox(strFormattted);
return;
}
}
}
在DELETE[]pBuf;行提示错误“error C2059: syntax error : ']'”,
请问是何原因?如何解决?


[解决办法]
大小写是有区分的,delete.
#define DELETE (0x00010000L)
[解决办法]

探讨
大小写是有区分的,delete.
#define DELETE (0x00010000L)

热点排行