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, "#", "@");