Take all middle characters in between first and last most *
for ( int z = first ; z <= last ; z ++ ) { if ( S [ i ] [ z ] != ' * ' ) mid += S [ i ] [ z ] ; } } reverse ( suff . begin ( ) , suff . end ( ) ) ; return pref + mid + suff ; }