istream::sync
int  sync ( );
istream
  cplusplus.com  

Syncronize stream's buffer with source of characters.
  Syncronizes the content of the stream's internal buffer with the physical source of characters associated with the stream.
 

Parameters.

none
 

Return Value.
  If function is successful it returns 0, otherwise EOF is returned.

Example.

// read a file into memory
#include <iostream>
using namespace std;

int main () {
  char first, second;

  cout << "Please, enter a word: ";
  first=cin.get();
  cin.sync();

  cout << "Please, enter another word: ";
  second=cin.get();

  cout << "The first word began by " << first << endl;
  cout << "The second word began by " << second << endl;

  return 0;
}
  This example demonstrates how sync behaves on cin, removing any unread character from the standard input character queue.

Basic template member declaration ( basic_istream<charT,traits> ):
int sync ();

See also.
  istream class


© The C++ Resources Network, 2001