iter = g_listPath.begin();//list.begin()回指向第一个元素
while (iter != g_listPath.end())
{
CNode curpos = *iter;
CString str;
CString strFileName="mytest.txt";
CFile file;
SYSTEMTIME st;
GetLocalTime(&st);
str.Format("%2d:%2d:%2d %d %d\r\n",st.wHour,st.wMinute,st.wSecond,curpos.X,curpos.Y);
file.Open(strFileName,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate);
file.SeekToEnd();
file.Write((LPCTSTR)str,str.GetLength());
file.Close();
++iter;
if (iter == g_listPath.end())
break;
}
这是关于写的!现在要把.txt中的坐标一行一行读进来,让程序再跑一边,求解答,麻烦大神帮忙写下读的代码!拜托了
使用CStdioFile 一行一行读取数据很方便
CStdioFile myFile;
if(myFile.Open(CBApp::getCurrModulePath()+_T("filename.txt"), CFile::modeRead))
{
while (myFile.ReadString(str))
{
//处理读到的每一行数据
}
myFile.Close();
}