std::basic_istream::putback
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í. |
basic_istream& putback( char_type ch ); |
||
Pone el carácter
ch de nuevo al flujo de entrada por lo que el siguiente carácter extraído será ch . Original:
Puts the character
ch back to the input stream so the next extracted character will be ch. 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.
Primero despeja
eofbit, entonces se comporta como UnformattedInputFunction. Después de la construcción y comprobación del objeto centinela, si rdbuf() no es nulo, llama rdbuf()->sputbackc(ch), que llama rdbuf()->pbackfail(ch) ch si no es igual al personaje más recientemente extraído .Original:
First clears
eofbit, then behaves as UnformattedInputFunction. After constructing and checking the sentry object, if rdbuf() is not null, calls rdbuf()->sputbackc(ch), which calls rdbuf()->pbackfail(ch) if ch does not equal the most recently extracted character.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 nulo o si vuelve rdbuf->sputbackc(ch) Traits::eof(), llama setstate(badbit) .Original:
If
rdbuf() is null or if rdbuf->sputbackc(ch) returns Traits::eof(), calls setstate(badbit).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.
En cualquier caso, establece el
gcount() contador a cero .Original:
In any case, sets the
gcount() counter to zero.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
*this
Ejemplo
demuestra la diferencia entre la modificación y no modificando-putback ()
Original:
demonstrates the difference between modifying and non-modifying putback()
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 <sstream>
#include <iostream>
int main()
{
std::stringstream s1("Hello, world"); // IO stream
s1.get();
if(s1.putback('Y')) // modifies the buffer
std::cout << s1.rdbuf() << '\n';
else
std::cout << "putback failed\n";
std::istringstream s2("Hello, world"); // input-only stream
s2.get();
if(s2.putback('Y')) // cannot modify input-only buffer
std::cout << s2.rdbuf() << '\n';
else
std::cout << "putback failed\n";
s2.clear();
if(s2.putback('H')) // non-modifying putback
std::cout << s2.rdbuf() << '\n';
else
std::cout << "putback failed\n";
}
Salida:
Yello, world
putback failed
Hello, world
Ver también
unextracts un carácter Original: unextracts a character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
lee el siguiente carácter sin extraerlo Original: reads the next character without extracting it The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) |