+ 1

How to remove a letter from a string in cpp?

https://code.sololearn.com/cQEwcInCG4ov/?ref=app

9th Jan 2021, 7:56 AM
Š”ŠøтŠ½ŠøŠŗŠ¾Š²Š° Š’Š°Ń€Š²Š°Ń€Š°
Š”ŠøтŠ½ŠøŠŗŠ¾Š²Š° Š’Š°Ń€Š²Š°Ń€Š° - avatar
5 Answers
+ 7
Please frame your question properly. In the question you are asking how to remove a letter from string, but in the code you are *replacing* a character in a string. The way you have used the replace method is wrong in your code. See here how to use it https://en.cppreference.com/w/cpp/string/basic_string/replace To erase a character from a string https://en.cppreference.com/w/cpp/string/basic_string/erase
9th Jan 2021, 8:17 AM
XXX
XXX - avatar
+ 5
You were just implementing replace method wrong way .This is how it should be done : s.replace(1,1, "y"); For more info https://www.javatpoint.com/cpp-string-replace-function
9th Jan 2021, 8:18 AM
Abhay
Abhay - avatar
+ 5
Do you want to remove a letter or replace a letter? your code suggested that you want to replace a letter by another.
9th Jan 2021, 8:19 AM
Ipang
+ 3
Thank you
9th Jan 2021, 8:21 AM
Š”ŠøтŠ½ŠøŠŗŠ¾Š²Š° Š’Š°Ń€Š²Š°Ń€Š°
Š”ŠøтŠ½ŠøŠŗŠ¾Š²Š° Š’Š°Ń€Š²Š°Ń€Š° - avatar