enum _Ios_Iostate
{
_S_goodbit = 0,
_S_badbit = 1L << 0,
_S_eofbit = 1L << 1,
_S_failbit = 1L << 2,
_S_ios_iostate_end = 1L << 16
};
iostate rdstate();
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in;
in.open("test.txt");
if ((in.rdstate() & ifstream::failbit) != 0)
cerr << "Error opening 'test.txt' file.\n";
return 0;
}
./rdstate
Error opening 'test.txt' file.
bool bad();
bool eof();
bool fail();
bool bad();
void clear(iostate flags = ios::goodbit);
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |