MFC中怎么把一个数组的数据写入TXT文件中

2024-10-29 00:23:54
推荐回答(2个)
回答1:

char* pszFileName="F:\\myfile.txt";
CStdioFile myFile;
CFileException fileException;
if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate),&fileException)
{
myFile.SeekToEnd();
myFile.WriteString(stime);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str1);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str2);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str3);
myFile.WriteString("\n");
myFile.Close();
MessageBox("文件写入成功","提示");
}
else
{
TRACE("Can't open file %s,error=%u\n",pszFileName,fileException.m_cause);
}

回答2:

C++怎么写就怎么写啊。。。