Espaces de noms
Variantes
Affichages
Actions

std::basic_istream::read

De cppreference.com
< cpp‎ | io‎ | basic istream

 
 
D'entrée / sortie de bibliothèque
I / O manipulateurs
C-style I / O
Tampons
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf (obsolète)
Cours d'eau
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstractions
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
Fichier E / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
Chaîne I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Tableau I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream (obsolète)
ostrstream (obsolète)
strstream (obsolète)
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Interface catégorie d'erreur
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category (C++11)
io_errc (C++11)
 
std::basic_istream
Les objets globaux
Original:
Global objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cin
wcin
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::basic_istream
basic_istream::~basic_istream
basic_istream::operator= (C++11)
Entrée formaté
Original:
Formatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::operator>>
Entrée non formaté
Original:
Unformatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::get
basic_istream::peek
basic_istream::unget
basic_istream::putback
basic_istream::getline
basic_istream::ignore
basic_istream::read
basic_istream::readsome
basic_istream::gcount
Positionnement
Original:
Positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::tellg
basic_istream::seekg
Divers
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sync
basic_istream::swap (C++11)
Classes de membres
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sentry
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator>>(std::basic_istream)
 
basic_istream& read( char_type* s, std::streamsize count );
Extrait les caractères depuis stream .
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.
Se comporte comme UnformattedInputFunction. Après la construction et la vérification de l'objet sentinelle, extrait les caractères et les stocke dans des endroits successifs du tableau de caractères dont le premier élément est pointé par s. Les personnages sont extraites et stockées jusqu'à ce que l'une des conditions suivantes est remplie:
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.
  • count caractères ont été extraites et stockées
    Original:
    count characters were extracted and stored
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • condition de fin de fichier se produit sur la séquence d'entrée (dans ce cas, setstate(failbit|eofbit) est appelé .
    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.

Sommaire

[modifier] Paramètres

s -
pointeur vers le tableau de caractères pour stocker les caractères
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 -
nombre de caractères à lire
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.

[modifier] Retourne la valeur

*this

[modifier] Exemple

read () est souvent utilisé pour les données binaires 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.

#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';
}

Résultat :

0x12121212

[modifier] Voir aussi

blocs inserts de caractères
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.

(fonction membre publique de std::basic_ostream) [edit]
extraits des données formatées
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.

(fonction membre publique) [edit]
extrait des blocs déjà disponibles de caractères
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.

(fonction membre publique) [edit]
extraits caractères
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.

(fonction membre publique) [edit]
caractères extraits jusqu'à ce que le caractère donné se trouve
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.

(fonction membre publique) [edit]
lit un fichier
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.

(fonction) [edit]