std::basic_istream::sync
De cppreference.com
< cpp | io | basic istream
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
int sync(); |
||
Synchronise le tampon d'entrée avec la source de données associée .
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.
Se comporte comme
UnformattedInputFunction
, sauf que gcount()
n'est pas affectée. Après la construction et la vérification de l'objet sentinelle,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.
si rdbuf() est un pointeur NULL, -1 rendements
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.
Dans le cas contraire, les appels rdbuf()->pubsync(). Si cette fonction renvoie -1, appelle setstate(badbit) et retourne -1. Sinon, retourne 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.
Sommaire |
[modifier] Paramètres
(Aucun)
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.
[modifier] Retourne la valeur
0 en cas de succès, -1 cas d'échec ou si le flux ne prend pas en charge cette opération (pas de tampon) .
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.
[modifier] Notes
Comme
readsome()
, il est défini par l'implémentation de savoir si cette fonction ne fait rien avec la bibliothèque fournis par flux. Le but est généralement de l'opération de lecture suivante, ramassez tous les changements qui ont été apportés à la séquence d'entrée associé, après la dernière mémoire tampon de flux se remplissait son domaine. Pour y parvenir, synchroniser () peut vider la zone get, ou il peut le remplir, ou il peut ne rien faire. Une exception notable est Visual Studio, où cette opération supprime l'entrée non traitée lorsqu'elle est appelée avec un flux d'entrée 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.
[modifier] Exemple
Illustre l'utilisation de flux d'entrée sync () avec le fichier d'entrée, mis en œuvre sur certaines plates-formes .
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'; }
Résultat possible :
Reading from the file abc Reading from the file, with sync() a23
[modifier] Voir aussi
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
synchronise les tampons avec la séquence de caractères associée 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. (fonction membre virtuelle protégée de std::basic_streambuf )
|
synchronise avec le dispositif de stockage sous-jacent 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. (fonction membre publique de std::basic_ostream )
|