c++-STL:删除子串

void deletesub(string &str,const string &sub,int n)
{
    int m,flag=0,num=0; //num是子串出现的次数
    while(flag==0)
    {
        m=str.find(sub);//在str中找子串sub,返回起点下标
        if(m<0)//没找到
            flag=1;
        else
        {
            str.erase(m,n);//删除子串,起点和sub长度
            num++;
        }
    }
    cout<

你可能感兴趣的:(数据结构和算法)