能清除字符串中出现的#字符

问题遇到的现象和发生背景

编写一个函数,能清除字符串中出现的#字符erase("he##1#hel#llo")--"hello"

用代码块功能插入代码,请勿粘贴截图
void show(string a)
{
    
    for (int i = 0; iif (a[i] =='#')
        {
            auto b = a.begin();
            a.erase(i);
        }
    }
    cout << a << endl;
}
int main()
{
    string a = "he##1#hel#llo";
    show(a);
}

运行结果及报错内容

he

我的解答思路和尝试过的方法

erase 删除函数将‘#’后面的字符全部删掉了 不知道还有没有更好的接替方法

不用erase的话,可以用定义一个string c="";在循环中,不是#字符的放到c中,最后输出c