CString fileName;
char* strText = "";
CString data;
fileName = "D:\\HEX\\a1";
//"C:\\Users\\Administrator\\Desktop\\a1"
CFile openfile(fileName, CFile::modeRead);
int i = 0;
openfile.SeekToBegin();
while(openfile.Read(strText, 40) != 0)//调试在这里出问题
{
data.Format("%s", strText);
AfxMessageBox(data);
i++;
openfile.Seek(40*i, CFile::begin);
}
openfile.Close();
try
{
CFile openfile(fileName, CFile::modeRead);
while(1)
{
char strText [41] = {0};
if(openfile.Read(strText, 40))
{
CString data(strText);
AfxMessageBox(data);
}
else
{
break;
}
}
openfile.Close();
}
catch(CFileException *e)
{
e->ReportError();
e->Delete();
}
char* pszFileName = "C://a1.txt";
CStdioFile myFile;
CFileException fileException;
CString str1 = _T("");
CString temp;
if (myFile.Open(pszFileName, CFile::typeText | CFile::modeReadWrite), &fileException)
{
myFile.SeekToBegin();
while (myFile.ReadString(temp)) {
str1 += temp;
}
}
else
{
TRACE("Can't open file %s,error=%u/n", pszFileName, fileException.m_cause);
}
MessageBox(str1);
myFile.Close();
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。