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

PREVIOUS NEXT
Code Example
Cpp :: error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ 
Cpp :: mkdir c++ 
Cpp :: const char to string 
Cpp :: cpp binary tree 
Cpp :: c++ fizzbuzz 
Cpp :: how to get an element in a list c++ 
Cpp :: cpp multidimensional vector 
Cpp :: how to make a typing effect c++ 
Cpp :: c++ enum 
Cpp :: overload stream insert cpp 
Cpp :: minimum value in array using c++ 
Cpp :: strlen in c++ 
Cpp :: cpp cin 
Cpp :: c++ clear char array 
Cpp :: file c++ 
Cpp :: C++ String Copy Example 
Cpp :: vector length c++ 
Cpp :: ue4 float to fstring 
Cpp :: std::iomanip c++ 
Cpp :: c++ encapsulation 
Cpp :: how to sort vector of struct in c++ 
Cpp :: c++ create thread 
Cpp :: number of digits in int c++ 
Cpp :: vector to string cpp 
Cpp :: a square plus b square plus c square 
Cpp :: C++, for-loop over an array array 
Cpp :: cpp string find all occurence 
Cpp :: length of number c++ 
Cpp :: comparing characters of a string in c++ 
Cpp :: c++ get whole line 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =