std::basic_istream::getline
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. |
basic_istream& getline( char_type* s, std::streamsize count ); |
(1) | |
basic_istream& getline( char_type* s, std::streamsize count, char_type delim ); |
(2) | |
Caractères extraits de cours d'eau jusqu'à la fin de la ligne (équivalent à getline(s, count, widen(’\n’)))
2) Original:
Extracts characters from stream until the end of line (equivalent to getline(s, count, widen(’\n’)))
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.
Caractères extraits de flux jusqu'à ce que le séparateur spécifié .
Original:
Extracts characters from stream until the specified delimiter.
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 comporte comme
UnformattedInputFunction
. Après la construction et la vérification de l'objet sentinelle, extrait les caractères de *this
et les a stockées à des emplacements successifs du tableau dont le premier élément est pointé par s
jusqu'à ce que l'un des cas suivants: (testé dans l'ordre indiqué)Original:
Behaves as
UnformattedInputFunction
. After constructing and checking the sentry object, extracts characters from *this
and stored them in successive locations of the array whose first element is pointed to by s
until any of the following occurs: (tested in the order shown)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.
- condition de fin de fichier se produit dans la séquence d'entrée (dans ce cas setstate(eofbit) est exécuté)Original:end of file condition occurs in the input sequence (in which case setstate(eofbit) is executed)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- la
c
caractère suivant disponible est le délimiteur, tel que déterminé par Traits::eq(c, delim). Le délimiteur est extrait (à la différence basic_istream::get()) et pris en compte pourgcount()
, mais n'est pas mémorisé .Original:the next available characterc
is the delimiter, as determined by Traits::eq(c, delim). The delimiter is extracted (unlike basic_istream::get()) and counted towardsgcount()
, but is not stored.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- count-1 caractères ont été extraits (dans lequel cas setstate(failbit) est exécuté) .Original:count-1 characters have been extracted (in which case setstate(failbit) is executed).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si la fonction d'extraire aucun caractère (par exemple, si count < 1), setstate(failbit) est exécuté .
Original:
If the function extracts no characters (e.g. if count < 1), setstate(failbit) is executed.
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.
Dans tous les cas, si
count>0
, il enregistre alors une CharT()
caractère nul dans l'emplacement successif suivant de la matrice et mises à jour .. gcount()
Original:
In any case, if
count>0
, it then stores a null character CharT()
into the next successive location of the array and updates gcount()
.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.
Sommaire |
[modifier] Notes
Parce que la condition n ° 2 est testé avant la condition n ° 3, la ligne d'entrée qui correspond exactement à la mémoire tampon, ne déclenche pas failbit .
Original:
Because condition #2 is tested before condition #3, the input line that exactly fits the buffer, does not trigger 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.
Parce que le caractère de terminaison est comptabilisée comme caractère extraite, entrée ligne vide ne déclenche pas failbit .
Original:
Because the terminating character is counted as extracted character, empty input line does not trigger 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.
[modifier] Paramètres
s | - | pointeur vers la chaîne de caractères pour stocker les caractères
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 | - | taille de la chaîne de caractères pointée par
s Original: size of character string pointed to by s The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
delim | - | délimitant caractère d'arrêter l'extraction à. Il est extrait mais pas mémorisé .
Original: delimiting character to stop the extraction at. It is extracted but not stored. 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
#include <iostream> #include <sstream> #include <vector> #include <array> int main() { std::istringstream input("abc|def|gh"); std::vector<std::array<char, 4>> v; for(std::array<char, 4> a; input.getline(&a[0], 4, '|'); ) { v.push_back(a); } for(auto& a : v) { std::cout << &a[0] << '\n'; } }
Résultat :
abc def gh
[modifier] Voir aussi
lire des données depuis un flux d'E / S dans une chaîne Original: read data from an I/O stream into a string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
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) | |
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) | |
extrait des blocs de caractères 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. (fonction membre publique) |