std::basic_string::substr — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
|
|
||
Retourne une sous-chaîne [pos, pos+count). Si la sous-chaîne demandée dépasse la fin de la chaîne, ou si count == npos, la sous-chaîne retourné est [pos, size()) .
Original:
Returns a substring [pos, pos+count). If the requested substring lasts past the end of the string, or if count == npos, the returned substring is [pos, size()).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
| pos | - | position du premier caractère à inclure Original: position of the first character to include The text has been machine-translated via Google Translate. |
| count | - | longueur de la chaîne Original: length of the substring The text has been machine-translated via Google Translate. |
Retourne la valeur
String contenant le [pos, pos+count) chaîne .
Original:
String containing the substring [pos, pos+count).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exceptions
std::out_of_range if pos > size().
Complexité
Linéaire dans count
Original:
Linear in count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#include <string> #include <iostream> int main() { std::string a = "0123456789abcdefghij"; std::string sub1 = a.substr(10); std::cout << sub1 << '\n'; std::string sub2 = a.substr(5, 3); std::cout << sub2 << '\n'; std::string sub3 = a.substr(12, 100); std::cout << sub3 << '\n'; }
Résultat :
Voir aussi
copies caractères Original: copies characters The text has been machine-translated via Google Translate. (fonction membre publique) [edit] | |