我想把一串字符串中的某个特定元素删了
从字符串中删除某个特定字符
#include <algorithm> //要包含这个头文件
str.erase(std::remove(str.begin(), str.end(), 'a'), str.end());
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str = "";
char ch = '\0';
cin >> ch >> str;
str.erase(std::remove(str.begin(), str.end(), ch), str.end());
cout << str << endl;
return 0;
}