STL-String tips

2017-01-16  本文已影响0人  yangqi916

1. 构造函数

substring constructor
Copies the portion of str that begins at the character position pos and spans len characters (or until the end of str, if either str is too short or if len is string::npos).

string (const string& str, size_t pos, size_t len = npos);

2. 成员函数

string substr (size_t pos = 0, size_t len = npos) const;




- [std::string::insert](http://www.cplusplus.com/reference/string/string/insert/)
Inserts additional characters into the [string](http://www.cplusplus.com/string) right before the character indicated by *pos* (or *p*):

  ```c++
string& insert (size_t pos,   size_t n, char c);

string& replace (size_t pos, size_t len, const string& str,
size_t subpos, size_t sublen);

上一篇下一篇

猜你喜欢

热点阅读