|
istream::syncpublic member function
int sync ( ); Synchronize input buffer with source of characters Synchronizes the buffer associated with the stream to its controlled input sequence. This effectively means that the unread characters in the buffer are discarded.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. ParametersnoneReturn ValueIf 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
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
|