求指教:readstring怎么回到开头

oktsl 2009-08-11 04:15:09
cstdiofile file
while(file.readstring(buff,128))
{
......
}
我读到file的最后了,下次怎么重新开始从头读,不想再OPEN一次了,谢谢
...全文
44 点赞 收藏 8
写回复
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyskytoday 2009-08-11
cstdiofile也是继承cfile类
用seek来指向头
cstdiofile file;
file.Seek(0,CFile::begin);
回复
yuhudie203 2009-08-11
还有一个 rewind(file);
回复
MoXiaoRab 2009-08-11

CStdioFile cfile(_T("Stdio_Seek_File.dat"), CFile::modeWrite |
CFile::modeCreate);
LONGLONG lOff = 1000;
ULONGLONG lActual = cfile.Seek(lOff, CFile::begin);

回复
oktsl 2009-08-11
谢谢楼上的兄弟
这论坛好快的速度
我是新人,再次感谢
回复
MoXiaoRab 2009-08-11
CStdioFile::Seek

virtual ULONGLONG Seek(
LONGLONG lOff,
UINT nFrom
);

Parameters
lOff
Number of bytes to move the pointer.

nFrom
Pointer movement mode. Must be one of the following values:

CFile::begin: Move the file pointer lOff bytes forward from the beginning of the file.

CFile::current: Move the file pointer lOff bytes from the current position in the file.

CFile::end: Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to seek into the existing file; positive values will seek past the end of the file.
回复
yuhudie203 2009-08-11
[Quote=引用 1 楼 happyparrot 的回复:]
用file.SeekToBegin()
[/Quote]
right
回复
zhuzhenlei 2009-08-11
[Quote=引用 1 楼 happyparrot 的回复:]
用file.SeekToBegin()
[/Quote]
、、
回复
快乐鹦鹉 2009-08-11
用file.SeekToBegin()
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告