Debian Codegraph @

yo/iostreams/examples/tiecerrcout.cc

raw
1 #include <iostream>
2 using namespace std;
3
4 int main()
5 {
6 cerr.tie(0); // untie
7 cout << "first (buffered) line to cout ";
8 cerr << "first (unbuffered) line to cerr\n";
9 cout << "\n";
10
11 cerr.tie(&cout); // tie cout to cerr
12 cout << "second (buffered) line to cout ";
13 cerr << "second (unbuffered) line to cerr\n";
14 cout << "\n";
15 }
16 /*
17 Generated output:
18
19 first (unbuffered) line to cerr
20 first (buffered) line to cout
21 second (buffered) line to cout second (unbuffered) line to cerr
22 */