29 Input/output library [input.output]

29.5 Iostreams base classes [iostreams.base]

29.5.3 Class ios_­base [ios.base] Static members [ios.members.static]

static bool sync_with_stdio(bool sync = true);
Returns: true if the previous state of the standard iostream objects was synchronized and otherwise returns false.
The first time it is called, the function returns true.
Effects: If any input or output operation has occurred using the standard streams prior to the call, the effect is implementation-defined.
Otherwise, called with a false argument, it allows the standard streams to operate independently of the standard C streams.
When a standard iostream object str is synchronized with a standard stdio stream f, the effect of inserting a character c by
fputc(f, c);
is the same as the effect of
for any sequences of characters; the effect of extracting a character c by
c = fgetc(f);
is the same as the effect of
c = str.rdbuf()->sbumpc();
for any sequences of characters; and the effect of pushing back a character c by
ungetc(c, f);
is the same as the effect of
for any sequence of characters.288
This implies that operations on a standard iostream object can be mixed arbitrarily with operations on the corresponding stdio stream.
In practical terms, synchronization usually means that a standard iostream object and a standard stdio object share a buffer.