+ 1
If a word contains an odd number of characters,you must replace the middle letter of the word use this sumbol "*"
Help😊
2 Respuestas
+ 11
#include <cstring> and use strlen() function to check the length of the string. If char count is odd, replace mid of string with * using half char count obtained by strlen().
E.g.
string text = "SoloLearn";
int count = strlen(text.c_str());
if (count%2 != 0)
{
text[count/2] = '*';
}