std::basic_istream::get
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_type get(); |
(1) | |
| basic_istream& get( char_type& ch ); |
(2) | |
| basic_istream& get( char_type* s, std::streamsize count ); |
(3) | |
| basic_istream& get( char_type* s, std::streamsize count, char_type delim ); |
(4) | |
| basic_istream& get( basic_streambuf& strbuf ); |
(5) | |
| basic_istream& get( basic_streambuf& strbuf, char_type delim ); |
(6) | |
Extrae personaje o personajes de la corriente .
Original:
Extracts character or characters from 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.
Todas las versiones se comportan como
1) UnformattedInputFunctions. Después de la construcción y comprobación del objeto centinela, estas funciones realizan los siguientes:Original:
All versions behave as
UnformattedInputFunctions. After constructing and checking the sentry object, these functions perform the following: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.
lee un carácter y lo devuelve si están disponibles. De lo contrario, devuelve Traits::eof() y conjuntos
2) failbit y eofbit .Original:
reads one character and returns it if available. Otherwise, returns Traits::eof() and sets
failbit and eofbit.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.
lee un carácter y lo almacena en
3) ch si están disponibles. De lo contrario, deja ch sin modificar y establece failbit y eofbit. Tenga en cuenta que esta función no está sobrecargado en los tipos signed char y unsigned char, a diferencia del operador >> carácter con formato de entrada .Original:
reads one character and stores it to
ch if available. Otherwise, leaves ch unmodified and sets failbit and eofbit. Note that this function is not overloaded on the types signed char and unsigned char, unlike the formatted character input operator>>.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.
mismo como get(s, count, widen('\n')), es decir, lee en la mayoría de los caracteres count-1 y los almacena en una cadena de caracteres apuntada por
4) s hasta '\n' se encuentra .Original:
same as get(s, count, widen('\n')), that is, reads at most count-1 characters and stores them into character string pointed to by
s until '\n' is found.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.
lee los caracteres y los almacena en las posiciones sucesivas de la matriz de caracteres cuyo primer elemento es apuntado por
s. Los caracteres se extraen y se almacenan hasta que cualquiera de las siguientes situaciones:Original:
reads characters and stores them into the successive locations of the character array whose first element is pointed to by
s. Characters are extracted and stored until any of the following occurs: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.
- n-1 caracteres se han guardadoOriginal:n-1 characters have been storedThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- condición de fin de archivo se produce en la secuencia de entrada (setstate(eofbit) se llama)Original:end of file condition occurs in the input sequence (setstate(eofbit) is called)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- el siguiente carácter de entrada disponible
cdelimes igual, como se determina por Traits::eq(c, delim). Este personaje no se extrae (a diferencia de basic_istream::getline())Original:the next available input charactercequalsdelim, as determined by Traits::eq(c, delim). This character is not extracted (unlike basic_istream::getline())The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si hay personajes fueron extraídos, llama setstate(failbit). En cualquier caso, si
5) count>0, un carácter nulo (CharT() se almacena en la siguiente posición sucesiva de la matriz .Original:
If no characters were extracted, calls setstate(failbit). In any case, if
count>0, a null character (CharT() is stored in the next successive location of the array.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.
Mismo como get(strbuf, widen('\n')), es decir, lee los caracteres disponibles y los inserta en el objeto basic_streambuf dado hasta '\n' se encuentra ..
6) Original:
same as get(strbuf, widen('\n')), that is, reads available characters and inserts them to the given basic_streambuf object until '\n' is found.
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.
lee los caracteres y los inserta a la secuencia de salida controlada por el objeto dado basic_streambuf caracteres se extrae y se inserta en
strbuf hasta cualquiera de las siguientes situaciones:.Original:
reads characters and inserts them to the output sequence controlled by the given basic_streambuf object. Characters are extracted and inserted into
strbuf until any of the following occurs: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.
- condición de fin de archivo se produce en la secuencia de entradaOriginal:end of file condition occurs in the input sequenceThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- insertar en el... secuencia de salida falla (en cuyo caso el carácter que no puede insertarse, no se extrae)Original:insert into the output sequence fails (in which case the character that could not be inserted, is not extracted)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- el siguiente carácter de entrada disponible
cdelimes igual, como se determina por Traits::eq(c, delim). Este personaje no se extrae .Original:the next available input charactercequalsdelim, as determined by Traits::eq(c, delim). This character is not extracted.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- produce una excepción (en cuyo caso se detecta la excepción y no vuelve a iniciar)Original:an exception occurs (in which case the exception is caught and not rethrown)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si no hay caracteres se extrajeron, llamadas setstate(failbit) .
Original:
If no characters were extracted, calls setstate(failbit).
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.
Todas las versiones establecer el valor de
gcount() al número de caracteres extraídos .Original:
All versions set the value of
gcount() to the number of characters extracted.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.
Contenido |
[editar] Parámetros
| ch | - | referencia al carácter se escribe el resultado a
Original: reference to the character to write the result to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| s | - | puntero a la cadena de caracteres para almacenar los caracteres a
Original: pointer to the character string to store the characters to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| count | - | tamaño de la cadena de caracteres apuntada por
sOriginal: size of character string pointed to by sThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| delim | - | delimitando carácter para detener la extracción a. No es extraída y almacenada no .
Original: delimiting character to stop the extraction at. It is not extracted and not stored. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| strbuf | - | búfer de la secuencia para leer el contenido
Original: stream buffer to read the content to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar] Valor de retorno
1)el carácter extraído o Traits::eof()
Original:
the extracted character or Traits::eof()
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.
2-6) *this
[editar] Ejemplo
#include <sstream> #include <iostream> int main() { std::istringstream s1("Hello, world."); char c1 = s1.get(); // reads 'H' std::cout << "after reading " << c1 << ", gcount() == " << s1.gcount() << '\n'; char c2; s1.get(c2); // reads 'e' char str[5]; s1.get(str, 5); // reads "llo," std::cout << "after reading " << str << ", gcount() == " << s1.gcount() << '\n'; std::cout << c1 << c2 << str; s1.get(*std::cout.rdbuf()); // reads the rest, not including '\n' std::cout << "\nAfter the last get(), gcount() == " << s1.gcount() << '\n'; }
Output:
after reading H, gcount() == 1 after reading llo,, gcount() == 4 Hello, world. After the last get(), gcount() == 7
[editar] Ver también
| extrae los bloques de caracteres Original: extracts blocks of characters The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| extractos de formato de datos Original: extracts formatted data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| extrae caracteres y arrays de caracteres Original: extracts characters and character arrays The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función de plantilla) | |