开发者社区> 问答> 正文

c++string类的查找操作

请问c++中find_first_of函数的具体的使用方法,尽量具体一些?

展开
收起
a123456678 2016-03-06 11:04:18 1895 0
1 条回答
写回答
取消 提交回答
  • #include // std::cout
    #include // std::string
    #include // std::size_t
    
    int main ()
    {
    std::string str ("Please, replace the vowels in this sentence by asterisks.");
    std::size_t found = str.find_first_of("aeiou");
    while (found!=std::string::npos)
    {
    str[found]='*';
    found=str.find_first_of("aeiou",found+1);
    }
    
    std::cout << str << '\n';
    
    return 0;
    }

    Edit & Run

    Pl*s, rplc th vwls n ths sntnc by strsks.

    2019-07-17 18:54:18
    赞同 展开评论 打赏
问答分类:
C++
问答地址:
问答排行榜
最热
最新

相关电子书

更多
使用C++11开发PHP7扩展 立即下载
GPON Class C++ SFP O;T Transce 立即下载
GPON Class C++ SFP OLT Transce 立即下载