This substring is the character sequence that starts at character position pos and has a length of n characters.
Parameters
- pos
- Position of a character in the current string object to be used as starting character for the substring.
If the position passed is past the end of the string, an out_of_range exception is thrown. - n
- Length of the substring.
If this value would make the substring to span past the end of the current string content, only those characters until the end of the string are used.
npos is a static member constant value with the greatest possible value for an element of type size_t, therefore, when this value is used, all the characters between pos and the end of the string are used as the initialization substring.
Return Value
A string object containing a substring of the current object.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
generalities live in details. |
Basic template member declarations
( basic_string<charT,traits,Allocator> )| 1 2 |
|
See also
| string::replace | Replace part of string (public member function) |
| string::data | Get string data (public member function) |
| string::find | Find content in string (public member function) |
| string::insert | Insert into string (public member function) |
| string::append | Append to string (public member function) |
