#include <string>
#include <algorithm>
std::string str = "afafas";
std::replace(str.begin(), str.end(), 'a', '1');