Common member function
string substr (size_t pos = 0, size_t len = npos) const;
Returns a new one
A copy of the String object that is initialized to a substring of the String object.
substring is the part of the object that starts at character position pos and spans len characters (or up to the end of the string, whichever comes first).
The position of the first character is copied as a substring.
this function returns an empty string if this is equal to the length of the string.
if this is greater than the length of the string, it will throw out_of_range.
note: the first character is represented as the value 0 (not 1).
The number of characters included in the subscript (if the string is short, as many characters as possible can be used as needed).
string :: non-profit value represents all characters up to the end of the string.
size_t is an unsigned integral type (the same as member type)
The return value A
String Object with a substring of this object.
think live in details.
- Differences between length() size() and C strlen() of C + + string member functions
- C++ foundation — clear/erase/pop of string class_back
- error: unclosed character literal (How to Fix)
- In Java, int is converted to string, and zero is added before the number of bits is insufficient
- A repeated string is composed of two identical strings. For example, abcabc is a repeated string with length of 6, while abcba does not have a duplicate string. Given any string, please help Xiaoqiang find the longest repeated substring.
- 12-web security — error injection based on SQL Server — and, convert, cast
- Java compareto() method
- error: invalid use of non-static member function
- [Warning] incompatible implicit declaration of built-in function ‘strcat’
- Solve the problem of error: cannot pass objects of non trivially copyable type ‘STD:: String’ in C / C + +
- Format control of cout cout.width () and cout.fill ()
- Error in comparing the size function of STL with negative number
- Conversion from hexadecimal to decimal
- Translate() and maketrans() methods of string in Python
- The differences between the equals method in the string class and the equals method in the object class
- CIN in C + + cin.get ()、 cin.getline (), getline(), gets() function
- [Two Sigma OA] Longest Chain
- vector length_error
- C++ cin.ignore Use of ()
- C / C + + library function (tower / tower) realizes the conversion of letter case