Skip to main content
fixed and clarified variable names as per anonymous user's suggestion
Source Link
UncleZeiv
  • 18.6k
  • 7
  • 53
  • 77

I thought I'd toss in the boost solution as well:

#include <boost/algorithm/string/replace.hpp> // in place std::string inputin_place = "blah#blah"; boost::replace_all(resultin_place, "#", "@"); // copy const std::string input2input = "blah#blah"; std::string resultoutput = boost::replace_all_copy(input2input, "#", "@"); 

I thought I'd toss in the boost solution as well:

#include <boost/algorithm/string/replace.hpp> // in place std::string input = "blah#blah"; boost::replace_all(result, "#", "@"); // copy const std::string input2 = "blah#blah"; std::string result = boost::replace_all_copy(input2, "#", "@"); 

I thought I'd toss in the boost solution as well:

#include <boost/algorithm/string/replace.hpp> // in place std::string in_place = "blah#blah"; boost::replace_all(in_place, "#", "@"); // copy const std::string input = "blah#blah"; std::string output = boost::replace_all_copy(input, "#", "@"); 
Source Link
UncleZeiv
  • 18.6k
  • 7
  • 53
  • 77

I thought I'd toss in the boost solution as well:

#include <boost/algorithm/string/replace.hpp> // in place std::string input = "blah#blah"; boost::replace_all(result, "#", "@"); // copy const std::string input2 = "blah#blah"; std::string result = boost::replace_all_copy(input2, "#", "@");