How can I make a text replacer in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I make a text replacer in c++?

What I mean by that is a program that detects for example all the a's in a text I give him and replaces them with b's. How do I do that?

7th Sep 2018, 7:17 PM
Elias Kamakas
Elias Kamakas - avatar
4 Answers
7th Sep 2018, 7:29 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 7
string str = "An apple a day, keeps the doctor away"; for (int i = 0; i < str.size(); i++) { if(str[i] == 'a' ) str[i] = 'b' ; }
7th Sep 2018, 7:22 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
Thanks guys!
7th Sep 2018, 10:07 PM
Elias Kamakas
Elias Kamakas - avatar