std::basic_istream::sync
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
int sync(); |
||
Sincroniza el buffer de entrada con la fuente de datos asociada .
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 comporta como
UnformattedInputFunction, excepto que gcount() no se ve afectada. Después de la construcción y comprobación del objeto centinelaOriginal:
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() es un puntero NULL, devuelve
-1Original:
if rdbuf() is a null pointer, returns
-1The 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.
De lo contrario, las llamadas
rdbuf()->pubsync(). Si la función devuelve -1, llama setstate(badbit) y vuelve -1. De lo contrario, devuelve 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.
Parámetros
(Ninguno)
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.
Valor de retorno
0 en caso de éxito, -1 en caso de fallo o si la secuencia no admite esta operación (es 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.
Notas
Al igual que con
readsome(), es definido por la implantación si esta función no hace nada con suministrados biblioteca arroyos. La intención es normalmente para leer la siguiente operación para recoger las modificaciones que se han realizado en la secuencia de entrada correspondiente después de la última memoria de flujo lleno obtener su área. Para lograrlo, sincronizar () puede vaciar la zona get, o puede rellenarlo, o puede no hacer nada. Una excepción notable es Visual Studio, donde esta operación descarta la entrada sin procesar cuando se llama con un flujo de entrada estándar .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.
Ejemplo
Muestra el uso de corriente de entrada de sincronización () con el archivo de entrada, tal como se aplica en algunas plataformas .
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.
Ejecuta este código
#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';
}
Posible salida:
Reading from the file
abc
Reading from the file, with sync()
a23
Ver también
[virtual] |
Sincroniza los búferes con la secuencia de caracteres asociada. (función miembro virtual protegida de std::basic_streambuf<CharT,Traits>)
|
(función miembro pública de std::basic_ostream<CharT,Traits>)
|