您当前的位置: 首页 > 

txwtech

暂无认证

  • 2浏览

    0关注

    813博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

CStdioFile类逐行读写日志记录文件

txwtech 发布时间:2016-04-05 21:51:01 ,浏览量:2



写入文件的例子 //创建文件 CStdioFile file; file.Open("ts.txt",CFile::modeCreate|CFile::modeWrite); //写入文件 CString str; str.Format("%s\r\n","hello!I am talkingmute!");(在末尾添加\r\n会导致写出来的文档修改后出现格式错乱,只能写\n) file.Seek(0,CFile::end); file.WriteString( str ); //关闭文件 file.Close(); 比如:读文件的例子 CString strText = “”; CString szLine = “”; //打开文件 CStdioFile file; file.Open("ts.txt",CFile::modeRead); //逐行读取字符串 while( file.ReadString( szLine ) ) { strText += szLine; } MessageBox(strText); //关闭文件 file.Close();

关注
打赏
1665060526
查看更多评论
立即登录/注册

微信扫码登录

0.0397s