If we have non - empty result , then insert all characters from first character to last character of string
if ( res_length > 0 ) for ( i = index - res_length + 1 ; i <= index ; i ++ ) res . push_back ( str [ i - 1 ] ) ; return res ; }