The function only has meaning for buffered streams, in which case it effectively calls the pubsync member of the streambuf object (rdbuf()->pubsync()) associated to the input sequence.
Parameters
noneReturn Value
If the stream is a buffered stream and the function is successful, zero is returned.If the stream is unbuffered, the function returns -1.
On error, the badbit flag is set (which can be checked with member bad). Also, depending on the values set through member exceptions, an exception may be thrown in this case.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
This example demonstrates how sync behaves on cin, removing any unread character from the standard input queue of characters.
Basic template member declaration
( basic_istream<charT,traits> ) |
See also
| ostream::flush | Flush output stream buffer (public member function) |
| streambuf::pubsync | Synchronize stream buffer (public member function) |
