std::basic_istream::read
Da cppreference.com.
< cpp | io | basic istream
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
basic_istream& read( char_type* s, std::streamsize count ); |
||
Estrae i caratteri dal flusso.
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.
Si comporta come
UnformattedInputFunction
. Dopo la costruzione e la verifica dell'oggetto sentinella, estrae i caratteri e li memorizza in posizioni successive della matrice di caratteri il cui primo elemento è puntato da s
. Caratteri vengono estratti e memorizzati fino a qualsiasi delle seguenti condizioni: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.
- Caratteri
count
stati estratti e memorizzatiOriginal:count
characters 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.
- condizione di fine file avviene sulla sequenza di ingresso (in questo caso, è chiamato 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.
Indice |
[modifica] Parametri
s | - | puntatore alla matrice di caratteri per memorizzare i caratteri
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 | - | numero di caratteri da leggere
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. |
[modifica] Valore di ritorno
*this
[modifica] Esempio
read () viene spesso usato per binari 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.
#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'; }
Output:
0x12121212
[modifica] Vedi anche
blocchi inserti di caratteri Original: inserts 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. (metodo pubblico) | |
estratti i dati formattati 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. (metodo pubblico) | |
estrae blocchi già disponibili di caratteri 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. (metodo pubblico) | |
estratti di caratteri Original: extracts characters The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
caratteri estratti fino a quando il carattere dato è stato trovato Original: extracts characters until the given character is found The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
legge da un file 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. (funzione) |