大神们,请问如何使用erase函数

我想把一串字符串中的某个特定元素删了

img

从字符串中删除某个特定字符

#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;
}

img