13.9. Tying an Output Stream to an Input Stream
Interactive applications generally involve an
istream for input and an
ostream for output. When a prompting message appears on the screen, the user responds by entering the appropriate data. Obviously, the prompt needs to appear before the input operation proceeds. With output buffering, outputs appear only when the buffer fills, when outputs are flushed explicitly by the program or automatically at the end of the program. C++ provides member function tie to synchronize (i.e., “tie together”) the operation of an
istream and an
ostream to ensure that outputs appear before their subsequent inputs. The call
cin.tie( &cout );
istream). Actually, this particular call ...