本文整理汇总了C++中std::ios::fail方法的典型用法代码示例。如果您正苦于以下问题:C++ ios::fail方法的具体用法?C++ ios::fail怎么用?C++ ios::fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ios
的用法示例。
在下文中一共展示了ios::fail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
printstate(const std::ios &ios)
{
if (ios.good()) {
std::cout << "ios.good" << std::endl;
} else if (ios.eof()){
std::cout << "ios.eof" << std::endl;
} else if (ios.fail()){
std::cout << "ios.fail" << std::endl;
} else if (ios.bad()){
std::cout << "ios.bad" << std::endl;
}
}
示例2: print_state
//prints the error flags when an attempt to open a file fails
void util::print_state (const std::ios& stream) {
cerr << " good()=" << stream.good();
cerr << " eof()=" << stream.eof();
cerr << " fail()=" << stream.fail();
cerr << " bad()=" << stream.bad();
}
示例3: print_state
void print_state (const std::ios& stream) {
std::cout << " good()=" << stream.good();
std::cout << " eof()=" << stream.eof();
std::cout << " fail()=" << stream.fail();
std::cout << " bad()=" << stream.bad();
}
示例4: show_results
void show_results( std::ios& stm )
{
std::cout << std::boolalpha << "bad: " << stm.bad() << " fail: " << stm.fail()
<< " eof: " << stm.eof() << " good: " << stm.good()
<< " bool(stm): " << bool(stm) << " !stm: " << !stm << '\n' ;
}