cpp/io/ios base/sync with stdio

Sets whether the standard C++ streams are synchronized to the standard C streams after each input/output operation.

The standard C++ streams are the following: std, std, std, std, std, std, std and std.

The standard C streams are the following: stdin, stdout and stderr.

For a standard stream, synchronized with the C stream , the following pairs of functions have identical effect: @1@ and @2@ and @3@ and

In practice, this means that the synchronized C++ streams are unbuffered, and each I/O operation on a C++ stream is immediately applied to the corresponding C stream's buffer. This makes it possible to freely mix C++ and C I/O.

In addition, synchronized C++ streams are guaranteed to be thread-safe (individual characters output from multiple threads may interleave, but no data races occur).

If the synchronization is turned off, the C++ standard streams are allowed to buffer their I/O independently, which may be considerably faster in some cases.

By default, all eight standard C++ streams are synchronized with their respective C streams.

If this function is called after I/O has occurred on the standard stream, the behavior is implementation-defined: implementations range from no effect to destroying the read buffer.

Return value
synchronization state before the call to the function