怎样读取文本文件?

zhaozhaozhao 2003-06-22 03:07:45
部知怎样读取,有规律的文本文件,经请高人指点!
...全文
15 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Richuen22 2003-06-22
  • 打赏
  • 举报
回复
CStdioFile功能比较强些,当然用CFile也可以的。
wei_gogo 2003-06-22
  • 打赏
  • 举报
回复
CStdioFile fText;
BOOL bExist = fText.Open("unit3.txt",CFile::modeRead);
if (bExist)//判断这个文件必须存在,不然要出错
{
while(NULL != fText.ReadString(strFile))
{
//do sth.
}
}
zyleon 2003-06-22
  • 打赏
  • 举报
回复
CFile::Read
virtual UINT Read( void* lpBuf, UINT nCount );
throw( CFileException );

Return Value

The number of bytes transferred to the buffer. Note that for all CFile classes, the return value may be less than nCount if the end of file was reached.

Parameters

lpBuf

Pointer to the user-supplied buffer that is to receive the data read from the file.

nCount

The maximum number of bytes to be read from the file. For text-mode files, carriage return–linefeed pairs are counted as single characters.

Remarks

Reads data into a buffer from the file associated with the CFile object.

Example

//example for CFile::Read
extern CFile cfile;
char pbuf[100];
UINT nBytesRead = cfile.Read( pbuf, 100 );

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧