Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

14.6 Synchronization with the C Standard I/O

The predefined C++ streams cin, cout, cerr, and clog are associated with the standard C files stdin, stdout, and stderr, as we saw in Section 7.1. This means that insertions into cout, for instance, go to the same file as output to stdout. By default, input and output to the predefined streams are synchronized with read or write operations on the standard C files. The effect is that input and output operations are executed in the order of invocation, independently of whether the operations used the predefined C++ streams or the standard C files.

This synchronization is time-consuming and thus might not be desirable in all situations. You can switch it off by calling:

After such a call, the predefined streams operate independently of the C standard files, with possible performance improvements in your C++ stream operations. However, you should call sync_with_stdio() prior to any input or output operation on the predefined streams, because otherwise the effect of calling sync_with_stdio() is implementation-defined.



Previous fileTop of DocumentContentsIndexNext file

OEM Edition, OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.