that should have read:
i'm using an fstream to read a file multiple times:
Code:
fin.open(testdata,ios::in);//opens fstream as fin
if(fin.fail())
cerr << "error opening " << testdata << endl;
return;
then, when the file has been read once, i ask the pointer to return to the beginning of file:
Code:
if(fin.eof()){
cerr << "eof reached for fin"<<endl;
frame.MakeInvalid();//ignore
fin.seekp(0, std::ios::beg);
cerr<<"fin reset\n";
}
return 1;
expecting to be able to re-read the file the second time:
Code:
testinput::ReadInput(){
double tmp;
if(!fin.is_open()){
cerr <<"fin has failed inside ReadInput"<<endl;
fin.close();
cerr <<"re-opening\n";
cerr<<"passing "<<testdata<<" to istream:pen()\n";
fin.open(testdata,ios::in);
if(!fin.is_open())
cerr<<"re-open has failed on second attempt\n";
}
i expect fin to still be open, but if it isn't i ask it to reopen, but it fails. can anyone explain this?
(i am using vc++ and running the executable as a win32 console ap)