void CDuquwenjianView::OnFileOpen()
{
CFileDialog dlg(TRUE,_T("TXT"),_T("*.TXT"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("文本文件(*TXT)|*.TXT|"));
if(IDOK==dlg.DoModal())
{
FilePathname.Format("%s%s","filepath:",dlg.GetPathName());
FileName.Format("%s%s","filename:",dlg.GetFileName());
string filename;
filename=dlg.GetPathName();
ifstream infile1("filename");
string section;
int housenum=0;
int group=0;
while(getline(infile1,section))
{int i=(int)section.find(' ');
if(i==-1&§ion=="0")
++housenum;
}
infile1.close();
//得到文本中房子的数量
zancun.resize(housenum);
ifstream infile2("filename");
while(infile2>>section)
{
while(infile2>>section&§ion!="0")
{ istringstream istr(section);
double val=0;
istr>>val;
zancun[group].push_back(val);
}
++group;
}
infile2.close();
xianshi.Format("%d",zancun[2][3]);
}
Invalidate();
}
ondraw()
pDC->TextOut(0,0,xianshi);
为什么在读文件中存得容器数据在ondraw()中不能用,出现内存不能read问题