文本读写 CStdioFile流文件
2008-11-20 19:37:49 来源:WEB开发网核心提示:char*pFileName="test.txt";CStdioFilesf;if(!sf.Open(pFileName,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText)){#ifdef_DEBUGafxDump<<"
char*pFileName="test.txt";
CStdioFilesf;
if(!sf.Open(pFileName,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText))
{
#ifdef_DEBUG
afxDump<<"Unabletoopenfile"<<"n";
#endif
exit(1);
}
charaaa[]="aaan";// 'n':0x0A
char*bbb="bbb12";// '12':0x0A
CStringccc("ccc15");// '15':0x0D
sf.WriteString(aaa);
sf.WriteString(bbb);
sf.WriteString(ccc);
sf.WriteString("dddr");// 'r':0x0D
sf.Close();
CStdioFilesf2("test.txt",CFile::modeRead|CFile::typeText);
charbuf[8];
CStringstr;
LPTSTRlpstr=sf2.ReadString(buf,8);
AfxMessageBox(buf);
while(sf2.ReadString(str))
AfxMessageBox(str);
sf2.Close();
Tags:文本 读写 CStdioFile
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接