Search
 
SCRIPT & CODE EXAMPLE
 

CPP

removing a character from a string in c++

#include<iostream>
#include<algorithm>

using namespace std;
main() {
   string my_str = "ABAABACCABA";

   cout << "Initial string: " << my_str << endl;

   my_str.erase(remove(my_str.begin(), my_str.end(), 'A'), my_str.end()); //remove A from string
   cout << "Final string: " << my_str;
}
Comment

delete one specific character in string C++

#include <algorithm>
str.erase(std::remove(str.begin(), str.end(), 'a'), str.end());
Comment

str remove char c++

static  void StrRemoveChar(std::string& s1, char l)
{
  s1.erase(std::remove(s1.begin(), s1.end(), l), s1.end());
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: two elements with difference K in c++ 
Cpp :: how to format decimal palces in c++ 
Cpp :: system("pause") note working c++ 
Cpp :: how to convert string to int in c++ 
Cpp :: stl function to reverse an array 
Cpp :: how to create a c++ templeate 
Cpp :: char to int in c++ 
Cpp :: run c++ program mac 
Cpp :: c++ constructor call superclass 
Cpp :: exponent power of x using c c++ 
Cpp :: c++ forbids comparison between pointer and integer 
Cpp :: CRED Coins codechef solution in c++ 
Cpp :: trie code cpp 
Cpp :: get std string from file 
Cpp :: 1768. Merge Strings Alternately leetcode solution in c++ 
Cpp :: print reverse number 
Cpp :: copy constructor c++ syntax 
Cpp :: linear search 
Cpp :: volumeof a sphere 
Cpp :: C++ Quotient and Remainder 
Cpp :: cpp malloc 
Cpp :: swap alternate elements in an array c++ problem 
Cpp :: cpp undefined reference to function 
Cpp :: custom slider cpt wordpress theme 
Cpp :: Program to find GCD or HCF of two numbers c++ 
Cpp :: c++ threadpool 
Cpp :: C++ insert character 
Cpp :: how togreper 
Cpp :: C+++++++++++++++++++++++++++ JAVA 
Cpp :: the amount of input is unknown 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =