如何让写入log文件中的数据是一行一行的(急)

princesshan 2004-09-14 04:15:09
我要写入的信息是CString类型的,
HANDLE hFile;
hFile = CreateFile(strName, // open MYFILE.TXT
GENERIC_READ|GENERIC_WRITE , // open for reading
FILE_SHARE_READ, // share for reading
NULL, // no security
//OPEN_EXISTING, // existing file only
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Could not open file.",MSGTitle001,MB_OK|MB_ICONINFORMATION); // process error
}
CFile myFile((int)hFile);
CArchive arStore(&myFile, CArchive::store);
myFile.SeekToEnd( );

for(int i = 0; i < m_arrTaskItemInfo.GetSize (); i ++)
{

arStore.WriteString( _T("asdfdsfdf "));
}
arStore.WriteString( "\n" );
// Close the storing archive
arStore.Close();
CloseHandle(hFile);
内容写进入了,都在一行,希望是一行一行的,如何实现呀,我写入类型一定是CString类型的
...全文
263 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
西江残月 2004-09-14
  • 打赏
  • 举报
回复
原来地球人都知道啊
内存泄漏 2004-09-14
  • 打赏
  • 举报
回复
用文件流:
FILE* file;
file=fopen("cicqserver.ini","w");

fprintf(file,"%s","[IP]\n");
fprintf(file,"%s",m_ipaddr);
fprintf(file,"%s","\n");
fprintf(file,"%s","[PORT]\n");
fprintf(file,"%s",m_port);
fclose(file);
snaill 2004-09-14
  • 打赏
  • 举报
回复
同意楼上的
yinzhaohui 2004-09-14
  • 打赏
  • 举报
回复
加入\r\n
lixiaosan 2004-09-14
  • 打赏
  • 举报
回复
CStdioFile file;
if( !file.Open("d:\\1.txt", CFile::modeRead) )
{
AfxMessageBox("can not open file!");
return;
}

file.WriteString("1111\n");
file.Write("222\n");
flyelf 2004-09-14
  • 打赏
  • 举报
回复
WriteString("\r\n"); // 换行

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧