+ 1

How to add any letter in a string???

Like i want to add "a"in the end of every word of the sentence "hello how are you"

1st Dec 2020, 4:28 PM
Krish Mohan
Krish Mohan - avatar
4 Answers
+ 3
You can use "isspace" from the <cctype> header and the "insert" from the <string> header file in a simple "for loop"....but be careful...as you insert the letter, the space will move to the right and the same space will be picked up again indefinitely, If your stuck let me know...just....have a go.
1st Dec 2020, 7:18 PM
rodwynnejones
rodwynnejones - avatar
+ 2
Not so clear about where you want that 'a' to be placed, in beginning, end of word, or in middle, or random position? To improve clarity, show the result of that "hello how are you" sentence after you add the letter 'a'.
1st Dec 2020, 10:46 PM
Ipang