C++ 逐行读取txt文件

读取test.txt 文件内容
如:

aa.exe
bb.txt
cc.dat
    CFile file(_T("test.txt"), CFile::modeRead);
    char* pBuf;
    DWORD dwFileLen;
    dwFileLen = file.GetLength();
    pBuf = new char[dwFileLen + 1];
    pBuf[dwFileLen] = 0;
    file.Read(pBuf, dwFileLen);
    file.Close();
    CString str(pBuf);
    str.Replace(_T("\r\n"), _T("\\NADAFlash\\"));
    str = _T("\\NADAFlash\\") + str;
    MessageBox(str);

猜你喜欢

转载自blog.csdn.net/zuoyuexian/article/details/77887649