我改怎么在写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();