I want to write data stored in a vector into a file. Therefore I use the following routine:
bool Grid::saveToFile() {
stringstream sstream;
for (size_t i = 0; i < taglist.size(); ++i)
{
if (i != 0)
sstream << ",";
sstream << taglist[i];
}
string s = sstream.str();
CFileDialog FileDlg(FALSE);
if (FileDlg.DoModal() == IDOK) {
CString pathName = FileDlg.GetPathName();
CStdioFile outputFile(pathName, CFile::modeWrite | CFile::modeCreate);
outputFile.WriteString((LPCTSTR)s.c_str());
outputFile.Close();
return TRUE;
}
return FALSE;
}
The problem is: Although there's data in s, the output file is always NULL. Can anybody solve that mystery?