Answers for "how to remove particular character from string"

C++
3

delete one specific character in string C++

#include <algorithm>
str.erase(std::remove(str.begin(), str.end(), 'a'), str.end());
Posted by: Guest on September-24-2020
-1

take a string and a character, remove that character from string

cpp code
int main()
{
    string str;
    getline(cin,str);
    char c;
    cin>>c;
    
    string temp="";
    
    for(int i=0; i<str.size(); i++){
        
        if(str[i] == c)
          continue;
        temp += str[i];  
        
    }
    
    cout<<temp;

    return 0;
}
Posted by: Guest on August-11-2021

Code answers related to "how to remove particular character from string"

Browse Popular Code Answers by Language