| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1124 人关注过本帖
标题:我改怎么在写txt文档是换行写入?
取消只看楼主 加入收藏
goaler
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-7-4
收藏
 问题点数:0 回复次数:0 
我改怎么在写txt文档是换行写入?
我用CFile 类的的成员函数write()写数据到txt。中,想实现换行输入,怎么实现?
这是我写的代码。帮我看看!
file.Open("I:\\第6次试验.txt",CFile::modeCreate|CFile::modeReadWrite,NULL);
char headbuf[200],databuf[200];
CString strhead,strdata;
strhead.Format("%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s",
"TH","TMa","Pac","Ttit","Ptit","Pet","Tet","Qma","Tip","Tep","Pip","Pep","qv","Kp","N","FR","db");
int bytesinbuf=sprintf(headbuf,"%s\n",strhead);
file.Write(headbuf,bytesinbuf);
strdata.Format("%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f%-10f",
m_getdata.m_sTH,m_getdata.m_sTMA,m_getdata.m_sPAC,m_getdata.m_sTTIT,
m_getdata.m_sPTIT,m_getdata.m_sPET,m_getdata.m_sTET,m_getdata.m_sQMA,
m_getdata.m_sTIP,m_getdata.m_sTEP,m_getdata.m_sPIP,m_getdata.m_sPEP,
m_getdata.m_sQV,m_getdata.m_sKP,m_getdata.m_sN,m_getdata.m_sFR,m_getdata.m_sDB);
bytesinbuf=sprintf(databuf,"%s\n",strdata);
file.Write(databuf,bytesinbuf);
dwpositionview=file.GetPosition();
file.Close();
搜索更多相关主题的帖子: txt 文档 CFile Tep 
2006-09-14 12:24
快速回复:我改怎么在写txt文档是换行写入?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033956 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved