Write a program to input a string and replace all the occurrences of character T with @ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program to input a string and replace all the occurrences of character T with @

23rd Jan 2018, 2:08 PM
VEDANG BADHWAR
VEDANG BADHWAR - avatar
3 Answers
+ 5
Just do : replace(str.begin(), str.end(), 'T', '@'); // Basically does the same thing // as a for loop used to replace // each character.
23rd Jan 2018, 3:00 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
23rd Jan 2018, 2:14 PM
shobhit
shobhit - avatar
0
To see how it works: for (char &c : str) if (c == 'T') c = '&';
23rd Jan 2018, 8:50 PM
Timon Paßlick