std::string::substr
string substr (size_t pos = 0, size_t len = npos) const;
子串是,在字符位置pos開始,跨越len個字符(或直到字符串的結尾,以先到者爲準)對象的部分。
參數
- pos
- 第一個字符的位置被複製爲子串。
如果這是等於字符串的長度,該函數返回一個空字符串。
如果這是大於字符串的長度,它會拋出out_of_range。
注意:第一個字符表示爲值0(不是1)。 - len
- 字符數在子包括(如果字符串是短,儘可能多的字符可以在需要使用)。
字符串::非營利值表示的所有字符,直到字符串的結尾。
size_t is an unsigned integral type (the same as member type string::size_type).
返回值
A string object with a substring of this object.Example
|
|
Output:
think live in details. |