+ 1
How to remove a letter from a string in cpp?
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
+ 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
+ 5
Do you want to remove a letter or replace a letter? your code suggested that you want to replace a letter by another.
+ 3
Thank you