If you are trying to change eg. "happy" to "happiest"
try to see if this code is what you are looking for:
1 2 3 4 5 6
string sample = "Happy";
if ( sample[ sample.length()-1 ] == 'y' ) // if the last character in the string is a 'y'
{
sample[ sample.length()-1 ] = 'i'; // change that 'y' into an 'i'
sample += "est"; // add "est" to the string
}