16,472
社区成员
发帖
与我相关
我的任务
分享
try
{
CString strLine(_T(""));
CString strText(_T(""));
map<CString, CString> strMap;
int curPos = 0;
LPCTSTR szToken = _T(" ");
int nIndex = 0;
CString strName(_T(""));
CString strValue(_T(""));
CStdioFile file;
file.Open(_T("F:\\11.txt"), CFile::modeRead);
while(file.ReadString(strLine))
{
curPos = 0;
strName.Empty();
strValue.Empty();
while(_T("") != (strText = strLine.Tokenize(szToken, curPos)))
{
if(0 == (nIndex++ % 2))
{
strName = strText;
}
else
{
strValue = strText;
}
}
strMap.insert(make_pair<CString, CString>(strName, strValue));
}
file.Close();
LPCTSTR szPath = _T("F:\\11.ini");
for(map<CString, CString>::const_iterator iter = strMap.begin(); iter != strMap.end(); iter++)
{
WritePrivateProfileString(_T("pathloss"), iter->first, iter->second, szPath);
}
}
catch (CFileException* e)
{
e->ReportError();
e->Delete();
}