How to delete one specific character from string in C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>

int main() {
 
    std::string str = "c++ c c# javascript python";
    char ch = 'c';     
     
    str.erase(std::remove(str.begin(), str.end(), ch), str.end());
 
    std::cout << str;
}
 
 
 
 
/*
run:
 
++  # javasript python
 
*/

 



answered Feb 21, 2022 by avibootz

Related questions

...