流云の剑舞秋风

吾生也有涯 而知也无涯

博客园 首页 新随笔 联系 订阅 管理
char *pFileName="test.txt";
    CStdioFile sf;
    
if(!sf.Open(pFileName,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText))
    {
#ifdef _DEBUG
        afxDump
<<"Unable to open file"<<"\n";
#endif
        exit(
1);
    }

    
char aaa[]="aaa\n";//        '\n' :0x0A 
    char *bbb="bbb\12";//        '\12':0x0A
    CString ccc("ccc\15");//    '\15':0x0D
    
    sf.WriteString(aaa);
    sf.WriteString(bbb);
    sf.WriteString(ccc);
    sf.WriteString(
"ddd\r");//    '\r' :0x0D

    sf.Close();

    CStdioFile sf2(
"test.txt",CFile::modeRead|CFile::typeText);
    
char buf[8];
    CString str;
    LPTSTR lpstr
=sf2.ReadString(buf,8);
    AfxMessageBox(buf);
    
while(sf2.ReadString(str))
        AfxMessageBox(str);
    sf2.Close();
posted on 2005-05-16 15:03  流云  阅读(1183)  评论(1编辑  收藏  举报