CFileDialog cfd(TRUE);
cfd.m_ofn.lpstrTitle=L"打开文本文件";
cfd.m_ofn.lpstrFilter=L"文本文件(*.txt)\0*.txt\0所有文件(*.*)\0*.*\0\0";
if(IDOK == cfd.DoModal())
{
CFile file(cfd.GetPathName(),CFile::modeRead);
wchar_t *pbuf;
ULONGLONG len;
len=file.GetLength()+1;
pbuf=new wchar_t[len];
pbuf[len]=0;
file.Read(pbuf,len);
file.Close();
MessageBox(pbuf);点击导入按钮,显示乱码,不知道哪里出错,请指点
cfd.m_ofn.lpstrTitle=L"打开文本文件";
cfd.m_ofn.lpstrFilter=L"文本文件(*.txt)\0*.txt\0所有文件(*.*)\0*.*\0\0";
if(IDOK == cfd.DoModal())
{
CFile file(cfd.GetPathName(),CFile::modeRead);
wchar_t *pbuf;
ULONGLONG len;
len=file.GetLength()+1;
pbuf=new wchar_t[len];
pbuf[len]=0;
file.Read(pbuf,len);
file.Close();
MessageBox(pbuf);点击导入按钮,显示乱码,不知道哪里出错,请指点
pbuf[len]=0;//越界了,改成pbuf[len-1]=0;
pbuf[len]=0;//越界了,改成pbuf[len-1]=0;