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

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 :: Setting a number of decimals on a float on C++ 
Cpp :: string vector to string c++ 
Cpp :: c++ filesystem read directory 
Cpp :: how to delete a node c++ 
Cpp :: fizzbuzz c++ 
Cpp :: erase element from vector c++ 
Cpp :: stack overflow c++ 
Cpp :: C++ float and double Different Precisions For Different Variables 
Cpp :: if statement c++ 
Cpp :: letter occurrence in string c++ 
Cpp :: insertion sort cpp 
Cpp :: macros in c++ 
Cpp :: c++ in cmd 
Cpp :: quicksort 
Cpp :: inserting element in vector in C++ 
Cpp :: cpp detect os 
Cpp :: find a number in vector c++ 
Cpp :: c++ check if debug or release visual studio 
Cpp :: map count function c++ 
Cpp :: unpack tuple c++ 
Cpp :: c++ recursion 
Cpp :: find pair with given sum in the array 
Cpp :: how to empty a std vector 
Cpp :: QVariant to int 
Cpp :: cmake g++ address sanitizer 
Cpp :: how to format big numbers with commas in c++ 
Cpp :: c++ cin 
Cpp :: c++ std map initializer list 
Cpp :: remove whitespace in cpp 
Cpp :: web dev c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =