Fraser Ross wrote in message
If the failbit becomes set after calling close() what issues are there?
Will subsequent calls to open() fail even after calling clear()? If the
buffer was flushed will the file be ok despite close() setting the
failbit?
Fraser.
Try this, then post again.
#include <iostream> // C++
#include <ostream> // std::endl
#include <fstream>
#include <string>
#include <vector>
// ------------------------------------
void TestFileBinaryPing( std:

stream &cout ){
std::string File1( "putaname1.type" ); <-- fill these in
std::string File2( "putaname2.type" );
std::ifstream Ping(File1.c_str(), std::ios_base::binary );
if(!Ping){
cout<<"\n ifstream 1 FAILED"<<std::endl;
}
cout<<" ifstream Ping.tellg() = "<<Ping.tellg()<<std::endl;
Ping.seekg(0, std::ios::end);
cout<<" Ping.seekg(0, ios::end) Ping.tellg() =
"<<Ping.tellg()<<std::endl;
Ping.seekg(0, std::ios::beg);
cout<<" Ping.seekg(0, ios::beg) Ping.tellg() =
"<<Ping.tellg()<<std::endl;
std::vector<unsigned char> Image;
char In(0);
while( Ping.get(In) ){
Image.push_back( static_cast<unsigned char>( In ) );
}
cout<<"\n Image.size() = "<<Image.size()<<" bytes."<<std::endl;
cout<<" ifstream Ping.tellg() = "<<Ping.tellg()<<std::endl;
Ping.close();
// note: use the SAME stream
Ping.open(File2.c_str(), std::ios_base::binary );
if(!Ping){
cout<<"\n ifstream 2 FAILED"<<std::endl;
}
cout<<" Ping.good() = "<<Ping.good()<<std::endl;
Ping.seekg(0, std::ios::end);
cout<<" Ping.seekg(0, ios::end) Ping.tellg() =
"<<Ping.tellg()<<std::endl;
// note: now clear stream, and note how it works
Ping.clear();
Ping.seekg(0, std::ios::end);
cout<<" Ping.clear(); Ping.seekg(0, ios::end) Ping.tellg() = "
<<Ping.tellg()<<std::endl;
cout<<" Ping.good() = "<<Ping.good()<<std::endl;
Ping.seekg(0, std::ios::beg);
cout<<" Ping.seekg(0, ios::beg) Ping.tellg() = "
<<Ping.tellg()<<std::endl;
Ping.get(In);
cout<<std::endl;
// ------------------------------------
return;
}
// ------------------------------------
int main(){
TestFileBinaryPing( std::cout );
return 0;
}
// ------------------------------------
[Please excuse the 'naming', I copied out of a testing program.]