文件指针移动无效?
szzfl 2007-01-20 06:57:30 temp.txt文件的内容为:
abcdefg
void main(int argc, char* argv[])
{
fstream file("temp.txt",ios::in |ios::binary);
char ch;
int i(0);
while(!file.eof())
{
file.read(&ch,1);
i++;
}
cout<<i-1<<endl; //文件长度
int a;
file.seekg(ios::beg);
a=file.tellg();
cout<<a<<endl; //显示为0
file.read(&ch,1);
cout<<ch<<endl; //怎么这里显示为g??文件指针已经置头了?
}