string:删除string中指定位置的字符?指定的所有字符?

版权声明:本博客为记录本人学习过程而开,内容大多从网上学习与整理所得,若侵权请告知! https://blog.csdn.net/Fly_as_tadpole/article/details/82809834

删除string中指定位置的字符

 string str = "huehfudhfruhgfsfgkhdyfsghydff";
 string::iterator itr = str.begin();
 itr += 2;
 str.erase(itr);

删除string中指定的所有字符

 str.erase(std::remove(str.begin(), str.end(), 'e'), str.end());

猜你喜欢

转载自blog.csdn.net/Fly_as_tadpole/article/details/82809834
今日推荐