Libreria C ++ basic_ios - sincronizzazione
Descrizione
Viene utilizzato per sincronizzare il buffer di input.
Dichiarazione
Di seguito è riportata la dichiarazione per std :: basic_istream :: sync.
int sync(); 
    Parametri
nessuna
Valore di ritorno
Se la funzione fallisce, o perché nessun oggetto buffer di flusso è associato al flusso (rdbuf è null) o perché la chiamata al suo membro pubsync fallisce, restituisce -1. Altrimenti, restituisce zero, indicando il successo.
Eccezioni
Basic guarantee - se viene generata un'eccezione, l'oggetto è in uno stato valido.
Gare di dati
Modifica l'oggetto stream.
Esempio
Nell'esempio seguente per std :: basic_istream :: sync.
#include <iostream>     
int main () {
   char first, second;
   std::cout << "Please, enter a word: ";
   first = std::cin.get();
   std::cin.sync();
   std::cout << "Please, enter another word: ";
   second = std::cin.get();
   std::cout << "The first word began by " << first << '\n';
   std::cout << "The second word began by " << second << '\n';
   return 0;
} 
    L'output dovrebbe essere così -
Please, enter a word: test
Please enter another word: text
The first word began by t
The second word began by t 
                        