#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file("out.txt", ios_base::app);
file.seekg(0, ios_base::beg);
char buffer[100];
if( !file.getline(buffer, 99) )
cout << "file.failbit " << boolalpha << file.fail() << " file.eofbit " << file.eof()
<< '\n'
<< "file.badbit " << file.bad() << " file.goodbit " << file.good() << '\n';
}
输出