If you're just adding 1 to each character, this will suffice:
Code:
for_each(s.begin(),s.end(),[](char& c){c++;});
Otherwise make a lookup table, denoting which char to be replaced by what:
Code:
void rep(char& c)//replaces everything with 'a'
{
bool up_flag(c>='A'&&c<='Z');
if(up_flag)c=tolower(c);
static char table[]=
{
'a','a','a','a','a',
'a','a','a','a','a',
'a','a','a','a','a',
'a','a','a','a','a',
'a','a','a','a','a',
'a'
};
c = table[c-'a'];
if(up_flag)c=toupper(c);
}
//call like this:
for_each(s.begin(),s.end(),rep);