c++ 函数 删除字符串指定位置的字符
c++ 函数 删除字符串指定位置的字符
日期:2019-10-16 17:28:55 人气:1
C++中的string类中有erase成员函数,其功能是删除字符串中的字符或字符串。
该成员函数的原型为
string
erase(int
start,
int
len);
//start为要删除字符的起始位置(从0数起),len为要删除字符的个数。
例如:
...
#include
using
namespace
std;
...
string
s1="asdfgh",
s2;
s2=s1.erase(2,3);
/