c++ dev/null
#include <iostream>
void foo()
{
std::cout << "Boring message. " << std::endl;
}
int main()
{
std::cout.setstate(std::ios::failbit) ;
foo();
std::cout.clear() ;
std::cout << "Interesting message." << std::endl;
return 0;
}