怎样获得CFile.Read读到的字符数?

Liulingbing 2003-10-17 08:23:27
RT
...全文
155 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zoohoo 2003-10-17
  • 打赏
  • 举报
回复
就是read函数的返回值嘛,如下:
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.

njuhuangmy 2003-10-17
  • 打赏
  • 举报
回复
如标题 所说, Read 函数必须指定读入的长度的阿

当然,这个 cfile.Read(buf, size); 读入的长度应该 是 小于 等于 size 的!!

返回值 就是 读入的长度
njuhuangmy 2003-10-17
  • 打赏
  • 举报
回复
文件的打开 之类 就不说它了

cfile.GetLength() 取得 文件的大小
cfile.SeekToBegin() 确保返回 文件头
cfile.Read() 读入
Liulingbing 2003-10-17
  • 打赏
  • 举报
回复
或者这样问,怎么样把一个CFile关联的字符文件所有字符读到一个CString对象里。
Liulingbing 2003-10-17
  • 打赏
  • 举报
回复
The number of bytes is not equal to the chacater readed.

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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