我前段时间在学习字符串(string),它里面有一个.erase()函数,它现在很迷幻,有两个用法
1:删除了点位的一个字符
int main ()
{
string str ("Fight for all the good in the world");
(为世界上所有美好而战)
string::iterator it;
// 第1种用法
it=str.begin()+6;
str.erase (it);
cout << str << endl; // "Fight or all the good in the world"
return 0;
}
2:
int main ()
{
string str ("Fight for all the good in the world");
(为世界上所有美好而战)
string::iterator it;
// 第2种用法
str.erase (5);
cout << str << endl; // "Fight"
return 0;
}
宣传一下博文(关于字符串的)