std::basic_istream::sync
Da cppreference.com.
< cpp | io | basic istream
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
int sync(); | ||
Sincronizza il buffer di input con l'origine dati associata.
Original:
Synchronizes the input buffer with the associated data source.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Si comporta come
UnformattedInputFunction
, salvo che gcount()
non è interessato. Dopo la costruzione e la verifica dell'oggetto sentinella,Original:
Behaves as
UnformattedInputFunction
, except that gcount()
is not affected. After constructing and checking the sentry object,The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
se rdbuf() è un puntatore nullo, restituisce -1
Original:
if rdbuf() is a null pointer, returns -1
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Altrimenti, le chiamate rdbuf()->pubsync(). Se tale funzione restituisce -1, chiama setstate(badbit) e ritorna -1. In caso contrario, restituisce 0.
Original:
Otherwise, calls rdbuf()->pubsync(). If that function returns -1, calls setstate(badbit) and returns -1. Otherwise, returns 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica]Parametri
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Valore di ritorno
0 in caso di successo, -1 in caso di fallimento o se il flusso non supporta questa operazione (è unbuffered).
Original:
0 on success, -1 on failure or if the stream does not support this operation (is unbuffered).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Note
Come
readsome()
, è definito dall'implementazione se questa funzione fa qualcosa con biblioteca fornita flussi. L'intento è in genere per l'operazione successiva lettura per raccogliere tutte le modifiche che potrebbero essere apportate alla sequenza di input associato dopo buffer del flusso ultima compilazione di tutta la zona di ottenere. A tal fine, la sincronizzazione () può svuotare l'area get, o può riempirla, o può fare nulla. Una notevole eccezione è Visual Studio, in cui questa operazione elimina l'ingresso non elaborato quando viene chiamato con un flusso di input standard.Original:
As with
readsome()
, it is implementation-defined whether this function does anything with library-supplied streams. The intent is typically for the next read operation to pick up any changes that may have been made to the associated input sequence after the stream buffer last filled its get area. To achieve that, sync() may empty the get area, or it may refill it, or it may do nothing. A notable exception is Visual Studio, where this operation discards the unprocessed input when called with a standard input stream.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Esempio
Viene illustrato l'utilizzo di sincronizzazione in ingresso corrente () con file di input, come attuato su alcune piattaforme .
Original:
Demonstrates the use of input stream sync() with file input, as implemented on some platforms.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>#include <fstream>void file_abc(){std::ofstream f("test.txt"); f <<"abc\n";}void file_123(){std::ofstream f("test.txt"); f <<"123\n";}int main(){ file_abc();// file now contains "abc"std::ifstream f("test.txt");std::cout<<"Reading from the file\n";char c; f >> c;std::cout<< c; file_123();// file now contains "123" f >> c;std::cout<< c; f >> c;std::cout<< c <<'\n'; f.close(); file_abc();// file now contains "abc" f.open("test.txt");std::cout<<"Reading from the file, with sync()\n"; f >> c;std::cout<< c; file_123();// file now contains "123" f.sync(); f >> c;std::cout<< c; f >> c;std::cout<< c <<'\n';}
Possible output:
Reading from the file abc Reading from the file, with sync() a23
[modifica]Vedi anche
[virtuale] | sincronizza i buffer con la sequenza di caratteri associata Original: synchronizes the buffers with the associated character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtuale protetto funzione of std::basic_streambuf membro) |
sincronizza con il dispositivo di archiviazione sottostante Original: synchronizes with the underlying storage device The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |