blogpro
//下面是一个检查一个字符串中是否有\'.\'的函数,该函数将找到的\'.\'转化为\'_\'。
inline void checkName(string& name)
{
std::string::size_type startpos = 0;
while (startpos!= std::string::npos)
{
    startpos = name.find(\'.\');   //找到\'.\'的位置
    if( startpos != std::string::npos ) //std::string::npos表示没有找到该字符
    {
      name.replace(startpos,1,"_"); //实施替换,注意后面一定要用""引起来,表示字符串
    }
}
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-11-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案