std::basic_istream::read
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& read( char_type* s, std::streamsize count ); |
||
Extrae caracteres de corriente .
Original:
Extracts 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.
Se comporta como
UnformattedInputFunction. Después de la construcción y comprobación del objeto centinela, extrae los caracteres y los almacena en 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 condiciones siguientes:Original:
Behaves as
UnformattedInputFunction. After constructing and checking the sentry object, extracts characters and stores them into successive locations of the character array whose first element is pointed to by s. Characters are extracted and stored until any of the following conditions 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.
countcaracteres se extraen y se almacenanOriginal:countcharacters were extracted and 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 (en cuyo caso, se llama
setstate(failbit|eofbit).Original:end of file condition occurs on the input sequence (in which case,setstate(failbit|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.
Parámetros
| s | - | puntero a la matriz de caracteres para almacenar los caracteres a
Original: pointer to the character array 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 | - | número de caracteres a leer
Original: number of characters to read The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Valor de retorno
*this
Ejemplo
leer () se utiliza a menudo para binarios I / O
Original:
read() is often used for binary I/O
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 <string>
#include <sstream>
#include <cstdint>
int main()
{
std::string bin = {'\x12', '\x12', '\x12', '\x12'};
std::istringstream raw(bin);
std::uint32_t n;
raw.read(reinterpret_cast<char*>(&n), 4);
std::cout << std::hex << std::showbase << n << '\n';
}
Salida:
0x12121212
Ver también
| Inserta un bloque de caracteres. (función miembro pública de std::basic_ostream<CharT,Traits>)
| |
| extraer datos con formato (función miembro pública) | |
extrae los bloques que ya están disponibles los personajes Original: extracts already available 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. (función miembro pública) | |
| Extrae caracteres. (función miembro pública) | |
| Extrae caracteres hasta que se encuentra el carácter dado. (función miembro pública) | |
lee un archivo Original: reads from a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función) |