c++ 去掉所有空格及换行符

  

//删除换行符

string get_string(string res){

  int r = res.find('\r\n');
  while (r != string::npos)
  {
    if (r != string::npos)
    {
      res.replace(r, 1, "");
      r = res.find('\r\n');
    }
  }

  //删除空格

  res.erase(std::remove_if(res.begin(), res.end(), std::isspace), res.end());

  return res;

}


猜你喜欢

转载自www.cnblogs.com/indifferent/p/11857744.html
今日推荐